Monitoring Backups with Uptime-Kuma

In my previous blog post on backups done right with Restic (https://blog.marcel-aust.de/backups-done-right-with-restic-2/ ), one crucial element of a robust backup strategy was missing: monitoring. While a well-configured backup setup is essential, it is equally important to ensure that the backups are functioning correctly and running as scheduled.
To address this, I utilize Uptime-Kuma (https://github.com/louislam/uptime-kuma ) for monitoring my backups. Although not specifically designed for this purpose, its integration with other parts of my infrastructure makes it an ideal choice.
Configure Backup Monitor

I employ a passive (push) monitor in Uptime-Kuma to receive daily heartbeats from my backup cronjob. Setting the check interval to 86400 seconds (24 hours) and the retry interval to 3600 seconds (1 hour), I expect one heartbeat per day, allowing for up to three hours of jitter due to potential network delays or extensive data processing.
For alerts, I use Pushover.net notifications sent to my iPhone, complemented by email monitoring for comprehensive coverage.
Send Status Heartbeat from backup script
My backup script begins with set -e
to halt execution upon any Restic command failure. A curl command at the script's end sends a heartbeat to Uptime-Kuma:
#!/bin/bash
START=$(date "+%s")
set -e
restic backup /home
restic backup /etc
...
END=$(date "+%s")
curl "https://example.com/api/push/abc123xyz?status=up&msg=OK&ping=$((END-START))"
This setup ensures no heartbeat is sent if an error occurs, as the script exits prematurely. The START
and END
variables capture execution time, enabling duration monitoring to detect potential anomalies.