improve logging

This commit is contained in:
Moritz 2024-10-15 18:04:53 +02:00
parent f877186a57
commit aeccd605ee

View File

@ -134,8 +134,7 @@ def restore(snapshot, target, noninteractive, volumes, container, no_commands):
for container, cmd in list(pre_commands.items()) + list(post_commands.items()): for container, cmd in list(pre_commands.items()) + list(post_commands.items()):
print(f"\t{container.labels['com.docker.swarm.service.name']}:\t{cmd}") print(f"\t{container.labels['com.docker.swarm.service.name']}:\t{cmd}")
print(f"This snapshot is {delta} old") print(f"This snapshot is {delta} old")
print( print("\nTHIS COMMAND WILL IRREVERSIBLY OVERWRITES FILES")
f"THIS COMMAND WILL IRREVERSIBLY OVERWRITES FILES AT {target}")
prompt = input("Type YES (uppercase) to continue: ") prompt = input("Type YES (uppercase) to continue: ")
if prompt != 'YES': if prompt != 'YES':
logger.error("Restore aborted") logger.error("Restore aborted")
@ -209,8 +208,9 @@ def parse_backup_labels(hook_type='backup', selected_container=[]):
post_hooks = settings['post_hooks'] = {} post_hooks = settings['post_hooks'] = {}
post_hooks[container] = command post_hooks[container] = command
else: else:
logger.error( logger.debug(f"Container {s.name} is not running.")
f"Container {s.name} is not running, hooks can not be executed") if labels.get(f'backupbot.{hook_type}.pre-hook') or labels.get(f'backupbot.{hook_type}.post-hook'):
logger.error(f"Container {s.name} contain hooks but it's not running")
return app_settings return app_settings
@ -356,8 +356,7 @@ def backup_volumes(backup_paths, apps, retries, dry_run=False):
logger.summary("backup finished", extra=result) logger.summary("backup finished", extra=result)
return return
except ResticFailedError as error: except ResticFailedError as error:
logger.error( logger.error(f"Backup failed for {SERVICE}.")
f"Backup failed for {apps}. Could not Backup these paths: {backup_paths}")
logger.error(error, exc_info=True) logger.error(error, exc_info=True)
if retries > 0: if retries > 0:
retries -= 1 retries -= 1