From 850270aae8f1210d94f6e1fa744865872ff64353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sun, 1 Nov 2026 08:32:38 +0000 Subject: [PATCH] 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 --- bin/stacks | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/stacks b/bin/stacks index ea3af68..cc87dca 100755 --- a/bin/stacks +++ b/bin/stacks @@ -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" }