Catch exceptions in backup_runner
This commit is contained in:
parent
c59f022a55
commit
0af9f2e8ee
|
@ -89,17 +89,27 @@ def backup(config, containers):
|
||||||
mounts = containers.generate_backup_mounts('/volumes')
|
mounts = containers.generate_backup_mounts('/volumes')
|
||||||
volumes.update(mounts)
|
volumes.update(mounts)
|
||||||
|
|
||||||
result = backup_runner.run(
|
try:
|
||||||
image=containers.this_container.image,
|
result = backup_runner.run(
|
||||||
command='restic-compose-backup start-backup-process',
|
image=containers.this_container.image,
|
||||||
volumes=volumes,
|
command='restic-compose-backup start-backup-process',
|
||||||
environment=containers.this_container.environment,
|
volumes=volumes,
|
||||||
source_container_id=containers.this_container.id,
|
environment=containers.this_container.environment,
|
||||||
labels={
|
source_container_id=containers.this_container.id,
|
||||||
"restic-compose-backup.backup_process": 'True',
|
labels={
|
||||||
"com.docker.compose.project": containers.project_name,
|
"restic-compose-backup.backup_process": 'True',
|
||||||
},
|
"com.docker.compose.project": containers.project_name,
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
except Exception as ex:
|
||||||
|
logger.exception(ex)
|
||||||
|
alerts.send(
|
||||||
|
subject="Exception during backup",
|
||||||
|
body=str(ex),
|
||||||
|
alert_type='ERROR',
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
logger.info('Backup container exit code: %s', result)
|
logger.info('Backup container exit code: %s', result)
|
||||||
|
|
||||||
# Alert the user if something went wrong
|
# Alert the user if something went wrong
|
||||||
|
@ -133,7 +143,7 @@ def start_backup_process(config, containers):
|
||||||
logger.error('Backup command exited with non-zero code: %s', vol_result)
|
logger.error('Backup command exited with non-zero code: %s', vol_result)
|
||||||
errors = True
|
errors = True
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error(ex)
|
logger.exception(ex)
|
||||||
errors = True
|
errors = True
|
||||||
|
|
||||||
# back up databases
|
# back up databases
|
||||||
|
@ -148,7 +158,7 @@ def start_backup_process(config, containers):
|
||||||
logger.error('Backup command exited with non-zero code: %s', result)
|
logger.error('Backup command exited with non-zero code: %s', result)
|
||||||
errors = True
|
errors = True
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.error(ex)
|
logger.exception(ex)
|
||||||
errors = True
|
errors = True
|
||||||
|
|
||||||
if errors:
|
if errors:
|
||||||
|
|
Loading…
Reference in New Issue