fix(backup): no last-backup time after a failed dump #12

Merged
jonnxor merged 1 commit from fix/backup-status-gate into main 2026-11-14 09:09:31 +00:00
Owner

What

The nightly backup no longer writes ~/Backups/status/last-backup after a run in which a dump failed or a Sögin dump was skipped. It says so on standard error, and the Sögin health page keeps the last good time until it reads Gamalt after 26 hours.

This is C-WR-03 of the Sögin phase 3.1 review (open threat T-03.1-60, gap G-03.1-1). Before, every dump swallowed its failure, so last-backup got a fresh time after a snapshot that held a stale or missing dump.

How

  • DUMP_FAILED=0 at the top of backup/run.sh.
  • Each of the five dump functions (Forgejo, Uptime Kuma, Vaultwarden, Sögin Postgres, Sögin Media) sets it in its DUMP FAILED branch.
  • dump_sogin ("not running, skipping") and dump_sogin_media ("no volume, skipping") set it too, because the demo now runs both and a skipped Sögin dump means the snapshot lacks Sögin's data.
  • write_backup_status checks the flag first: when set it prints backup-status: not written, a dump failed or a Sögin dump was skipped; the health page keeps the last good time to standard error and returns 0.
  • write_backup_status is still the last step of the backup) branch. The exit status, the restic calls and the dumps are unchanged: a failed dump still lets the rest of the backup run.
  • backup/README.md says when last-backup is not written.

Two choices for you

  1. Which skips hold the time back. The Forgejo, Uptime Kuma and Vaultwarden "not running" skips do NOT, because a deliberately stopped service is not a failed dump of Sögin's data. Only the Sögin Postgres and Sögin Media skips do. Say so if you want the other three to hold it back as well; that is a one-line change each.
  2. The stale dump file stays. After a failed dump the previous good file (sogin-dump.sql, sogin-media.tar, and so on) is left in place, so the snapshot still holds a restorable copy. The review's optional "rename the stale tar" is not taken.

Trial (stub podman first on PATH, mktemp folders, restic never called, no live container, volume or ~/Backups touched)

The desk keeps no test files and has no fmt, lint or test task for backup/; as in PR #11, the check is sh -n plus a trial that sources the functions.

  • RED against unchanged run.sh: dump_sogin failed, DUMP_FAILED did not exist, the trial exited 1.
  • sh -n backup/run.sh: ok.
  • Stub with ps listing sogin-postgres, volume exists yes, exec and volume export failing: dump_sogin sets the flag; dump_sogin_media sets the flag; write_backup_status writes no last-backup and prints the reason; with the flag back at 0 it writes 2026-11-13T19:34:36Z (ISO-8601 UTC), folder 755, file 644, only last-backup in the folder.
  • Stub with ps listing nothing and volume exists no: dump_forgejo, dump_kuma and dump_vaultwarden skip and leave the flag at 0; dump_sogin and dump_sogin_media skip and set it; the status folder is not created.
  • Stub with ps listing forgejo and exec failing: dump_forgejo's DUMP FAILED branch sets the flag.
  • grep -c 'DUMP_FAILED=1' backup/run.sh prints 7; write_backup_status is still the last line of the backup) branch; backup/include.txt is unchanged (no Backups/status).

After merging

git pull in ~/Projects/workdesk (the backup timer runs run.sh from that checkout). No backup needs to run now; the next nightly run uses the new script.

Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com

🤖 Generated with Claude Code

## What The nightly backup no longer writes `~/Backups/status/last-backup` after a run in which a dump failed or a Sögin dump was skipped. It says so on standard error, and the Sögin health page keeps the last good time until it reads Gamalt after 26 hours. This is C-WR-03 of the Sögin phase 3.1 review (open threat T-03.1-60, gap G-03.1-1). Before, every dump swallowed its failure, so `last-backup` got a fresh time after a snapshot that held a stale or missing dump. ## How - `DUMP_FAILED=0` at the top of `backup/run.sh`. - Each of the five dump functions (Forgejo, Uptime Kuma, Vaultwarden, Sögin Postgres, Sögin Media) sets it in its `DUMP FAILED` branch. - `dump_sogin` ("not running, skipping") and `dump_sogin_media` ("no volume, skipping") set it too, because the demo now runs both and a skipped Sögin dump means the snapshot lacks Sögin's data. - `write_backup_status` checks the flag first: when set it prints `backup-status: not written, a dump failed or a Sögin dump was skipped; the health page keeps the last good time` to standard error and returns 0. - `write_backup_status` is still the last step of the `backup)` branch. The exit status, the restic calls and the dumps are unchanged: a failed dump still lets the rest of the backup run. - `backup/README.md` says when `last-backup` is not written. ## Two choices for you 1. **Which skips hold the time back.** The Forgejo, Uptime Kuma and Vaultwarden "not running" skips do NOT, because a deliberately stopped service is not a failed dump of Sögin's data. Only the Sögin Postgres and Sögin Media skips do. Say so if you want the other three to hold it back as well; that is a one-line change each. 2. **The stale dump file stays.** After a failed dump the previous good file (`sogin-dump.sql`, `sogin-media.tar`, and so on) is left in place, so the snapshot still holds a restorable copy. The review's optional "rename the stale tar" is not taken. ## Trial (stub podman first on PATH, mktemp folders, restic never called, no live container, volume or `~/Backups` touched) The desk keeps no test files and has no fmt, lint or test task for `backup/`; as in PR #11, the check is `sh -n` plus a trial that sources the functions. - RED against unchanged `run.sh`: `dump_sogin` failed, `DUMP_FAILED` did not exist, the trial exited 1. - `sh -n backup/run.sh`: ok. - Stub with `ps` listing `sogin-postgres`, `volume exists` yes, `exec` and `volume export` failing: `dump_sogin` sets the flag; `dump_sogin_media` sets the flag; `write_backup_status` writes no `last-backup` and prints the reason; with the flag back at 0 it writes `2026-11-13T19:34:36Z` (ISO-8601 UTC), folder 755, file 644, only `last-backup` in the folder. - Stub with `ps` listing nothing and `volume exists` no: `dump_forgejo`, `dump_kuma` and `dump_vaultwarden` skip and leave the flag at 0; `dump_sogin` and `dump_sogin_media` skip and set it; the status folder is not created. - Stub with `ps` listing `forgejo` and `exec` failing: `dump_forgejo`'s `DUMP FAILED` branch sets the flag. - `grep -c 'DUMP_FAILED=1' backup/run.sh` prints 7; `write_backup_status` is still the last line of the `backup)` branch; `backup/include.txt` is unchanged (no `Backups/status`). ## After merging `git pull` in `~/Projects/workdesk` (the backup timer runs `run.sh` from that checkout). No backup needs to run now; the next nightly run uses the new script. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(backup): no last-backup time after a failed or skipped dump
All checks were successful
CI / sanity (pull_request) Successful in 7s
95fe02f60f
- DUMP_FAILED is set by every dump's DUMP FAILED branch and by the Sögin
  Postgres and Media skips (container or volume missing)
- write_backup_status prints why and writes nothing while it is set, so the
  health page keeps the last good time until it reads Gamalt (C-WR-03)
- exit status, restic calls and the dumps are unchanged

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
WAAAGH/_workdesk!12
No description provided.