Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Stop the backup daemon when a scheduled backup step fails (#5279)

Guih4713f48ebeed
diff --git a/bin/sure-backup b/bin/sure-backup
index dc16fc6eb3..9b48875a5f 100755
--- a/bin/sure-backup
+++ b/bin/sure-backup
@@ -780,7 +780,13 @@ cmd_daemon() {
log "Next backup in $((wait_s / 3600))h $((wait_s % 3600 / 60))m"
sleep "$wait_s" &
wait $!
- ( cmd_scheduled ) || warn "scheduled backup failed; retrying at the next scheduled time"
+ # Run the scheduled backup with set -e and capture its exit status, so a
+ # failed step stops the run before it reports "Done" or prunes old backups.
+ set +e
+ ( set -e; cmd_scheduled )
+ status=$?
+ set -e
+ [ "$status" -eq 0 ] || warn "scheduled backup failed; retrying at the next scheduled time"
done
}