Skip to content

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.

Free to start, no ads. Android 7 and up.

One line after the backup

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.

#!/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

exit 0 → {"heartbeat":true} · exit 10 → {"duplicate":false,"id":747}

#!/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.

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.

Get anypush

Free to start, no ads. Android 7 and up.