forked from coop-cloud/backup-bot-two
Allow selective path spec
This commit is contained in:
parent
ed687e52c3
commit
98b5f077e2
11
backupbot.py
11
backupbot.py
@ -85,6 +85,7 @@ def get_backup_cmds():
|
||||
services = client.services.list()
|
||||
for s in services:
|
||||
labels = s.attrs['Spec']['Labels']
|
||||
mounts = s.attrs['Spec']['Mounts']
|
||||
if (backup := labels.get('backupbot.backup')) and bool(backup):
|
||||
stack_name = labels['com.docker.stack.namespace']
|
||||
# Remove this lines to backup only a specific service
|
||||
@ -92,8 +93,14 @@ def get_backup_cmds():
|
||||
# if SERVICE and SERVICE != stack_name:
|
||||
# continue
|
||||
backup_apps.add(stack_name)
|
||||
backup_paths = backup_paths.union(
|
||||
Path(VOLUME_PATH).glob(f"{stack_name}_*"))
|
||||
for mount in mounts:
|
||||
if path := labels.get('backupbot.backup.path'):
|
||||
path_ = Path(VOLUME_PATH).glob(f"{stack_name}_{mount['Source']}/_data/{path}")
|
||||
else:
|
||||
path_ = Path(VOLUME_PATH).glob(f"{stack_name}_{mount['Source']}")
|
||||
logging.debug(
|
||||
f"Added backup path {path_}")
|
||||
backup_paths = backup_paths.union(path_)
|
||||
if not (container := container_by_service.get(s.name)):
|
||||
logging.error(
|
||||
f"Container {s.name} is not running, hooks can not be executed")
|
||||
|
Loading…
x
Reference in New Issue
Block a user