Backup failed? Get the alert on your phone, for restic and borg
One line after the backup. A failed restic or borg run buzzes your Android phone with the end of its log, a good run stays silent, and a backup that stops running alerts you too.
Send restic's exit status, and its last lines
Make a channel in the app and copy its address. Run the backup from a small script that posts restic's exit status to the address, with the end of the output as the body. 0 is a silent heartbeat. Any other status is a high-priority alert, "Exited with status N", whose text is the end of the log, so the notification already says what went wrong.
restic
#!/bin/sh # /usr/local/bin/backup.sh, run nightly by cron or a systemd timer export RESTIC_REPOSITORY=/srv/backup/restic export RESTIC_PASSWORD_FILE=/root/.restic-password ANYPUSH_URL=https://anypush.app/h/your-token out=$(restic backup /home /etc --exclude-caches 2>&1) status=$? printf '%s\n' "$out" | tail -n 20 | curl -fsS -m 10 --retry 3 --data-binary @- "$ANYPUSH_URL/$status" exit $status Answer: exit 0 → {"heartbeat":true} · exit 10 → {"duplicate":false,"id":747}
borg (not run here)
#!/bin/sh # the same pattern; borg 1.x exits 0 (success), 1 (warning) or 2 (error) out=$(borg create --stats "$BORG_REPO::{hostname}-{now}" /home /etc 2>&1) status=$? printf '%s\n' "$out" | tail -n 20 | curl -fsS -m 10 --retry 3 --data-binary @- "$ANYPUSH_URL/$status" exit $status The address is a secret: anyone who has it can send to your phone. Keep it in a file only root can read.
restic's exit codes, as the alert's title
The alert's title is the status, so you know the kind of failure before you open it. From restic's documentation (Scripting, Exit codes), which also says an unknown code "MUST be treated as a command failure":
| 0 | Command was successful: a silent heartbeat. |
| 1 | Command failed. |
| 3 | backup could not read some source data: a snapshot was made without those files. |
| 10 | Repository does not exist (since restic 0.17.0): a disk that is not mounted, a wrong path. |
| 11 | Failed to lock repository (since 0.17.0): another restic is running, or a stale lock. |
| 12 | Wrong password (since 0.17.1). |
| 130 | Command was cancelled (SIGINT or SIGTERM). |
borg 1.x: 0 success, 1 warning (the run reached its end, but check the log), 2 error, 128+N killed by signal N (borg's documentation, General, Return codes). To be told only about errors, send 0 for warnings too: [ $status -eq 1 ] && status=0.
The backup that never runs
A backup that fails can report itself. One that never starts cannot: a timer that was disabled, a server that was off at 3 a.m., a crontab that was replaced. Open the channel in the app and switch on Alert me if it goes quiet, with 1 day for a nightly backup (25 hours if its start time moves). Every good run starts that clock again; if none arrives, you get one alert about a minute after the day is up. The same works for any cron job.
Tested on 26 November 2026
restic 0.20.0 ran the script above against a test repository and a live channel on 26 November 2026. A good backup answered {"heartbeat":true} and sent no notification. A source file restic could not read made it exit 3, which arrived as "Exited with status 3" with restic's "permission denied" line as the text. A repository path that did not exist, exit 10, arrived with "Fatal: repository does not exist". A wrong password, exit 12, arrived with "Fatal: wrong password or no key found". The borg script was not run.
Sources
restic: Scripting, Exit codes. borg: General, Return codes. borgmatic has its own monitoring hooks, ntfy among them (How to monitor your backups): its ntfy hook can point at a channel's address, as Uptime Kuma's and Healthchecks.io's ntfy options can.
Questions
Does a failed backup every night mean one alert a night?
Yes: one alert per run that fails. If the same job runs more often and keeps failing with the same status, you get at most one alert per clock hour for that status.
How long can the log be?
The alert shows the end of what you send, up to 4,096 characters. tail -n 20 keeps it to the lines that say what went wrong.
Will a good backup notify me?
No. Status 0 is a heartbeat: nothing in your inbox, no notification. To be told about good runs too, send a normal message instead (curl -d 'backup ok' to the address without the number).
Should this be my only backup check?
No. It tells you that a backup ran and how it exited, not that you can restore it. Test a restore now and then, with restic check and a real restore of a few files.
More recipes: cron job monitoring, GitHub Actions notifications, push notifications with curl, and everything a channel's address takes.
anypush is on Google Play: Free to start, no ads. Android 7 and up. The tested original of this recipe, with the other recipes, is on anypush.app.