aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:14:16 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:14:16 -0300
commitbcaf3db8a6a20d863ea5f672d5b76dc3884871a3 (patch)
treed1c068d4fc766924e17cb8176b6e78785ceae338
parent90bec87bff6f0ca92d36daa0a5186a8556827595 (diff)
downloadpuppet-backup-bcaf3db8a6a20d863ea5f672d5b76dc3884871a3.tar.gz
puppet-backup-bcaf3db8a6a20d863ea5f672d5b76dc3884871a3.tar.bz2
Borg: check exit codes globally
-rw-r--r--templates/borg.sh.erb34
1 files changed, 16 insertions, 18 deletions
diff --git a/templates/borg.sh.erb b/templates/borg.sh.erb
index c32d63e..eab1a43 100644
--- a/templates/borg.sh.erb
+++ b/templates/borg.sh.erb
@@ -71,9 +71,9 @@ borg create \
backup_exit=$?
-if [ "$backup_exit" != "0" ]; then
- fatal "Error creating snapshot"
-fi
+#if [ "$backup_exit" != "0" ]; then
+# fatal "Error creating snapshot"
+#fi
info "Pruning repository..."
@@ -92,21 +92,19 @@ borg prune \
prune_exit=$?
-if [ "$prune_exit" != "0" ]; then
- fatal "Error pruning repository"
+#if [ "$prune_exit" != "0" ]; then
+# fatal "Error pruning repository"
+#fi
+
+# Use highest exit code as global exit code
+global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
+
+if [ ${global_exit} -eq 1 ]; then
+ info "Backup and/or Prune finished with a warning"
+fi
+
+if [ ${global_exit} -gt 1 ]; then
+ fatal "Backup and/or Prune finished with an error"
fi
-# use highest exit code as global exit code
-#global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
-#
-#if [ ${global_exit} -eq 1 ];
-#then
-# info "Backup and/or Prune finished with a warning"
-#fi
-#
-#if [ ${global_exit} -gt 1 ];
-#then
-# info "Backup and/or Prune finished with an error"
-#fi
-#
#exit ${global_exit}