More logging cleanup

This commit is contained in:
Einar Forselv 2019-12-04 01:58:01 +01:00
parent 00cf68fa3e
commit bdf2ea5e41
1 changed files with 10 additions and 7 deletions

View File

@ -63,13 +63,11 @@ def backup(config, containers):
if containers.backup_process_running:
raise ValueError("Backup process already running")
logger.info("Initializing repository")
logger.info("Initializing repository (may fail if already initalized)")
# TODO: Errors when repo already exists
restic.init_repo(config.repository)
logger.info("Starting backup container..")
# Map all volumes from the backup container into the backup process container
volumes = containers.this_container.volumes
@ -106,8 +104,11 @@ def start_backup_process(config, containers):
# Back up volumes
try:
logger.info('Backing up volumes')
vol_result = restic.backup_files(config.repository, source='/backup')
logger.info('Volume backup exit code: %s', vol_result)
logger.debug('Volume backup exit code: %s', vol_result)
if vol_result != 0:
logger.error('Backup command exited with non-zero code: %s', vol_result)
# TODO: Alert
except Exception as ex:
logger.error(ex)
@ -120,7 +121,9 @@ def start_backup_process(config, containers):
instance = container.instance
logger.info('Backing up %s in service %s', instance.container_type, instance.service_name)
result = instance.backup()
logger.info('Exit code: %s', result)
logger.debug('Exit code: %s', result)
if result != 0:
logger.error('Backup command exited with non-zero code: %s', result)
# TODO: Alert
except Exception as ex:
logger.error(ex)