Allow selective path spec
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
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()
|
||||
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,9 +93,15 @@ 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}_*"))
|
||||
if not (container:= container_by_service.get(s.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")
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue