fix: handle not running container
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Moritz 2023-10-19 23:15:24 +02:00
parent 66e1c9617d
commit 2bb27aadc4

View File

@ -90,16 +90,16 @@ 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)
container = container_by_service.get(s.name) backup_paths = backup_paths.union(
if not container: Path(VOLUME_PATH).glob(f"{stack_name}_*"))
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
if prehook := labels.get('backupbot.backup.pre-hook'): if prehook := labels.get('backupbot.backup.pre-hook'):
pre_commands[container] = prehook pre_commands[container] = prehook
if posthook := labels.get('backupbot.backup.post-hook'): if posthook := labels.get('backupbot.backup.post-hook'):
post_commands[container] = posthook post_commands[container] = posthook
backup_paths = backup_paths.union(
Path(VOLUME_PATH).glob(f"{stack_name}_*"))
return pre_commands, post_commands, list(backup_paths), list(backup_apps) return pre_commands, post_commands, list(backup_paths), list(backup_apps)