From eaf8b5cc78ea0e46eea0d3f1c66be38cb89b66e9 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Wed, 4 Dec 2019 21:24:10 +0100 Subject: [PATCH] Send alert from the main container --- restic_compose_backup/cli.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/restic_compose_backup/cli.py b/restic_compose_backup/cli.py index 747dfc6..fd3531a 100644 --- a/restic_compose_backup/cli.py +++ b/restic_compose_backup/cli.py @@ -101,6 +101,14 @@ def backup(config, containers): ) logger.info('Backup container exit code: %s', result) + # Alert the user if something went wrong + if result != 0: + alerts.send( + subject="Backup process exited with non-zero code", + body=open('backup.log').read(), + alert_type='ERROR', + ) + def start_backup_process(config, containers): """The actual backup process running inside the spawned container""" @@ -142,13 +150,8 @@ def start_backup_process(config, containers): logger.error(ex) errors = True - # Alert the user if something went wrong if errors: - alerts.send( - subject="Backup process exited with non-zero code", - body=open('backup.log').read(), - alert_type='ERROR', - ) + exit(1) def alert(config, containers):