From 896121ef91d089bdb25b1c1d21551d0872741d65 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sun, 21 Aug 2016 21:46:32 +0200 Subject: [PATCH] Print steps if verbose and show the exit codes on error --- restic-cron | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/restic-cron b/restic-cron index 8c7e579..7fb06ed 100755 --- a/restic-cron +++ b/restic-cron @@ -37,17 +37,20 @@ if [ -z "$RESTIC_PASSWORD" ]; then fi # Create a new backup -restic $RESTIC_QUIET backup $HOME $RESTIC_BACKUP_OPTIONS - -if [ $? -ne 0 ]; then +test -z "$RESTIC_QUIET" && echo "I: Backup step…" +restic $RESTIC_QUIET backup $RESTIC_DIR $RESTIC_BACKUP_OPTIONS +status=$? +if [ $status -ne 0 ]; then notify "Unable to finish the backup!" exit 2 fi # Verify the backup +test -z "$RESTIC_QUIET" && echo "I: Check step…" restic $RESTIC_QUIET check - -if [ $? -ne 0 ]; then +status=$? +if [ $status -ne 0 ]; then + echo "E: Exit code was $status" notify "Repository check of the backup failed!" exit 3 fi