Notify via ntfy when the nightly backup fails #18

Merged
patrick merged 2 commits from feat/backup-failure-alert into main 2026-10-30 15:16:58 +00:00
Owner

Summary

A failing nightly backup only showed up in the journal. Now it sends an ntfy
message.

  • kernelwatch-backup.service gets OnFailure=kernelwatch-backup-failed.service,
    which runs the new kernelwatch notify-backup-failure. systemd-level, so it
    covers the timeout, OOM kills and crashes as well as handled errors, which an
    in-process try/except would miss.
  • High-priority message naming the newest backup still on disk (or "none") and
    pointing at journalctl -u kernelwatch-backup.
  • No ntfy_url: logs that there's nothing to send to and exits 0. ntfy
    unreachable: exits 1 (journal only). sudo kernelwatch notify-backup-failure
    tests delivery.
  • One message per failed run (a persistent failure nags nightly); no recovery
    message.
  • Installer ships the new unit; README and server.toml.example updated.

Not covered: a timer that never runs at all (host down); that needs a heartbeat.

Testing

make test: 183 tests pass (6 new): message contents, no backups, delivery
failure, no ntfy configured, the CLI command, and a guard that every
OnFailure= target is a shipped unit (systemd silently ignores a typo there).
systemd-analyze verify is clean apart from expected missing /opt paths.

Not run: the failure path under real systemd. After deploying:
sudo systemctl start kernelwatch-backup-failed sends the message.

🤖 Generated with Claude Code

## Summary A failing nightly backup only showed up in the journal. Now it sends an ntfy message. - `kernelwatch-backup.service` gets `OnFailure=kernelwatch-backup-failed.service`, which runs the new `kernelwatch notify-backup-failure`. systemd-level, so it covers the timeout, OOM kills and crashes as well as handled errors, which an in-process try/except would miss. - High-priority message naming the newest backup still on disk (or "none") and pointing at `journalctl -u kernelwatch-backup`. - No `ntfy_url`: logs that there's nothing to send to and exits 0. ntfy unreachable: exits 1 (journal only). `sudo kernelwatch notify-backup-failure` tests delivery. - One message per failed run (a persistent failure nags nightly); no recovery message. - Installer ships the new unit; README and `server.toml.example` updated. Not covered: a timer that never runs at all (host down); that needs a heartbeat. ## Testing `make test`: 183 tests pass (6 new): message contents, no backups, delivery failure, no ntfy configured, the CLI command, and a guard that every `OnFailure=` target is a shipped unit (systemd silently ignores a typo there). `systemd-analyze verify` is clean apart from expected missing /opt paths. Not run: the failure path under real systemd. After deploying: `sudo systemctl start kernelwatch-backup-failed` sends the message. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 2 commits 2026-10-30 15:14:08 +00:00
Sends a high-priority ntfy message that the nightly backup failed, naming the
newest backup still on disk. It exits 1 if the message can't be delivered and 0
(with a note on stderr) when ntfy isn't configured.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Notify via ntfy when the nightly backup fails
CI / tests (Python 3.10) (pull_request) Successful in 25s
CI / tests (Python 3.11) (pull_request) Successful in 24s
CI / tests (Python 3.12) (pull_request) Successful in 24s
CI / tests (Python 3.13) (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 3s
48960e6faf
kernelwatch-backup.service gets OnFailure=kernelwatch-backup-failed.service,
which runs notify-backup-failure, so timeouts, OOM kills and crashes are
reported as well as handled errors. The installer ships the new unit, and tests
check that every OnFailure= target is a real unit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
patrick merged commit e3013921d1 into main 2026-10-30 15:16:58 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#18