Allow selective path spec
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ed687e52c3
commit
98b5f077e2
13
backupbot.py
13
backupbot.py
@ -85,6 +85,7 @@ def get_backup_cmds():
|
|||||||
services = client.services.list()
|
services = client.services.list()
|
||||||
for s in services:
|
for s in services:
|
||||||
labels = s.attrs['Spec']['Labels']
|
labels = s.attrs['Spec']['Labels']
|
||||||
|
mounts = s.attrs['Spec']['Mounts']
|
||||||
if (backup := labels.get('backupbot.backup')) and bool(backup):
|
if (backup := labels.get('backupbot.backup')) and bool(backup):
|
||||||
stack_name = labels['com.docker.stack.namespace']
|
stack_name = labels['com.docker.stack.namespace']
|
||||||
# Remove this lines to backup only a specific service
|
# Remove this lines to backup only a specific service
|
||||||
@ -92,9 +93,15 @@ def get_backup_cmds():
|
|||||||
# if SERVICE and SERVICE != stack_name:
|
# if SERVICE and SERVICE != stack_name:
|
||||||
# continue
|
# continue
|
||||||
backup_apps.add(stack_name)
|
backup_apps.add(stack_name)
|
||||||
backup_paths = backup_paths.union(
|
for mount in mounts:
|
||||||
Path(VOLUME_PATH).glob(f"{stack_name}_*"))
|
if path := labels.get('backupbot.backup.path'):
|
||||||
if not (container:= container_by_service.get(s.name)):
|
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(
|
logging.error(
|
||||||
f"Container {s.name} is not running, hooks can not be executed")
|
f"Container {s.name} is not running, hooks can not be executed")
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user