Monitoring my restic backups with Uptime Kuma

I have a couple of restic backup containers running across my servers, all based on the resticker image. It’s a basic part of every server configuration I use. Backups are executed on cron schedules. But until today, I had no visibility into whether they actually succeeded. So I had no idea one of my backups didn’t run for some weeks due to some “locks” in the repository.

Since I already run Uptime Kuma for monitoring my blog and other self-hosted services, I figured I could use it for monitoring the backups as well. Turns out, it’s really simple.

Uptime Kuma has a “Push” monitor type: you create one, get a unique URL, and ping that URL whenever your backup finishes or whenever it fails. If the ping doesn’t arrive within the configured timeout, or the status is not “up”, Uptime Kuma alerts you.

The resticker image already ships with curl and supports post-backup hooks via environment variables. So all I needed was three lines per resticker container in my docker-compose.yml files:

POST_COMMANDS_SUCCESS: |-
curl -s "https://your-uptime-kuma/api/push/TOKEN?status=up&msg=OK"
POST_COMMANDS_FAILURE: |-
curl -s "https://your-uptime-kuma/api/push/TOKEN?status=down&msg=failed"
POST_COMMANDS_INCOMPLETE: |-
curl -s "https://your-uptime-kuma/api/push/TOKEN?status=down&msg=incomplete"

POST_COMMANDS_SUCCESS fires when everything goes fine. POST_COMMANDS_FAILURE triggers if the backup errored entirely. And POST_COMMANDS_INCOMPLETE covers the case where the backup ran but some files couldn’t be read.

Now after every backup, Uptime Kuma gets a heartbeat. If a backup fails or never runs, I’ll get notified on all the notification services I configured in Uptime Kuma and can act immediately to resolve the problem.

Interactions & Comments