Monitor restic backups with HookPulse check-ins
A small script runs restic backup and forget, then sends the exit status of the last step to HookPulse.
Updated
1Create the monitor
Add a routine named restic-backup and set how often the job runs. Its page shows the check-in URL: use it in place of https://hookpulse.net/in/YOUR_ID.
2Write the backup script
The && runs forget only after a good backup. $? is the status of the last command that ran, so a failed backup or a failed prune is reported.
#!/bin/sh
# /usr/local/bin/restic-backup.sh
export RESTIC_REPOSITORY=/srv/restic-repo
export RESTIC_PASSWORD_FILE=/root/.restic-password
restic backup /srv/data --quiet && restic forget --keep-daily 7 --keep-weekly 4 --prune --quiet
curl -fsS -m 10 --retry 3 "https://hookpulse.net/in/YOUR_ID/$?"3Schedule the script
Make it executable with chmod +x, then add this line to the crontab.
0 3 * * * /usr/local/bin/restic-backup.sh4Run it once
Run the script once. The routine shows the first check-in. From then on, a missed or failed run sends the alert.