healthchecks.io and Home Assistant
checking backups are triggered is easy, that they happen, less so
I've started using borg for backups for a lot of
things lately, since it's very easy to run and old and so hopefully most of the data loss bugs have been found
by other people already. I've mostly been using it with
borgmatic, which is a command wrapper around it
that provides a config file and some extra features - in particular, it can ping healthchecks.io
after a backup finishes (or if it fails) so that I can get emails telling me to go look at it if it failed or
didn't report success every 25 hours or less.
I was not looking forward to trying to make it run on HA as an addon, but fortunately there's a bunch of
addons for it already; I'm using
this fork, since it seemed to be the
most current. Unfortunately, it wraps just borg, not borgmatic, and so can't ping
healthchecks.io about the status.
Fortunately, Home Assistant is a big set of interlocking state machines and Python libraries exposed via yaml, so a first cut isn't too hard.
I created a Restful Command in
configuration.yaml (after adding the Restful Command integration):
# Set up a REST service to ping healthchecks.io after a backup is uploaded
rest_command:
borgbase_upload_done:
url: "https://hc-ping.com/1234q43124-23123-1231231231"
(note: no trailing slash on the url).
then the automation:
alias: Upload backup to Borgbase
description: ""
trigger:
- platform: time_pattern
hours: "0"
minutes: "25"
seconds: "0"
action:
- service: hassio.addon_start
data:
addon: acbacaf121_borg_backup
- service: rest_command.borgbase_upload_done
data: {}
I've set healthchecks.io to complain via email if that end point isn't hit every 24+1(grace)
hours.
HOWEVER, this just checks the automation runs, it does not check that the backup did anything - it just starts the Borg Backup addon and then sends a post. I'll have to think about how to make that work better, but in the meantime I do have alerting on the backup destination to complain if it doesn't see any new data every day.