fix(stacks): fail loudly when restic prune fails
A stale restic lock made 'forget --prune' fail silently every night (only a warning), so the repo was never pruned. Now a prune failure is logged as an error, sends a red notification and exits non-zero. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
244358a99e
commit
850270aae8
1 file changed
+12
-2
+12
-2
@@ -650,8 +650,11 @@ _backup_run() {
|
||||
|
||||
# --- Prune ---
|
||||
log "Pruning old snapshots"
|
||||
restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6 2>&1 \
|
||||
|| warn "restic forget failed"
|
||||
local prune_failed=false
|
||||
if ! restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6 2>&1; then
|
||||
err "restic forget/prune failed (stale lock? try: restic unlock)"
|
||||
prune_failed=true
|
||||
fi
|
||||
|
||||
# --- Summary ---
|
||||
local snapshot_info repo_stats summary
|
||||
@@ -664,6 +667,13 @@ _backup_run() {
|
||||
[[ -n "$snapshot_info" ]] && summary+="\nLatest: \`$snapshot_info\`"
|
||||
[[ -n "$repo_stats" ]] && summary+="\nRepo: $repo_stats"
|
||||
|
||||
if $prune_failed; then
|
||||
summary+="\n❌ **Prune FAILED** — repo is growing unpruned (stale lock?). Check \`journalctl -u stacks-backup\`."
|
||||
_notify "#cc0000" "$summary"
|
||||
err "Backup saved, but prune failed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
_notify "#36a64f" "$summary"
|
||||
log "Backup complete"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user