Guide · Backups
Monitor backups with a dead man's switch
A backup job that crashes loudly is easy to catch. One that quietly stops running, because a cron entry got deleted, a credential expired, or a host was rebuilt without it, is invisible until the day you need to restore. One check-in call closes that gap.
1. Create a check
Create a check in Mortemain with your backup's schedule and grace window, then copy its unique ping URL:
https://ping.mortemain.com/your-check-uuid
2. Check in when the backup finishes
Add one request to the end of the job, reached only if everything before it succeeded. A plain GET or POST to the base URL is enough:
#!/bin/sh CHECK_URL="https://ping.mortemain.com/your-check-uuid" # ... your backup command(s) here ... /usr/local/bin/run-backup.sh && \ curl -fsS -o /dev/null "$CHECK_URL"
3. Alert immediately on failure
Don't just wait for the check-in to go missing, tell Mortemain the moment the job fails so you're paged straight away instead of at the end of the grace window:
if /usr/local/bin/run-backup.sh; then curl -fsS -o /dev/null "$CHECK_URL" else curl -fsS -o /dev/null "$CHECK_URL/fail" fi
4. Optional: track how long it takes
Ping /start right before the backup begins and the base URL when it finishes. Mortemain then measures the run's duration, so a backup that starts on time but silently hangs still gets caught:
curl -fsS -o /dev/null "$CHECK_URL/start" /usr/local/bin/run-backup.sh && curl -fsS -o /dev/null "$CHECK_URL" \ || curl -fsS -o /dev/null "$CHECK_URL/fail"
5. Pick your backup tool
The pattern above is the same everywhere: check in on success, ping /fail on error. Here's the exact hook for the tools we get asked about most:
PostgreSQL (pg_dump)
Wrap pg_dump and check in on a clean exit code.
rsync
Check in only when the sync itself exits clean.
BorgBackup
Ping after backup and prune, not just the first step.
Restic
Check in on backup, and on forget/prune too.
Duplicati
Use its run-script hooks to check in without touching the job.
Synology Hyper Backup
A GUI-only tool, wired up with its notification script hook.
TrueNAS
Post-script hooks on Cloud Sync and replication tasks.
Veeam
A post-job script that proves the backup actually finished.
Test it
Run the backup once: the check flips to up within a second or two. Then disable the job (or comment out the cron line) and wait past the grace window, you should get a down alert with nothing else needed. That's the whole point: the alert fires because nothing happened, not because something crashed.