A simple Python script and Docker image to check automatically check the recovery availability of your borgmatic backups.
First of all, you need to generate a SHA256 hash file somewhere in your backup repository.
mkdir /my/files/.check
cd /my/files/.check
sha256sum ../images/foo.img ../docs/important.txt > autochecksums
The paths to the files in the checksum file must be relative to the checksum file so that the script can pick up their location from the repository archive relative to the checksum file.
After that, you can run the checks using the provided Dpcker image.
docker run \
--name borgmatic-check \
--rm \
--detach \
--volume "/etc/borgmatic/config.yaml:/etc/borgmatic/config.yaml:ro" \
--volume "$HOME/.ssh/id_ed25519:/etc/ssh_keys/id_ed25519:ro" \
--volume "$HOME/.ssh/id_ed25519.pub:/etc/ssh_keys/id_ed25519.pub:ro" \
--env "LOG_LEVEL=info" \
--env "CHECK_FILES=/my/files/.check/autochecksums" \
--env "NTFY_URL=https://ntfy.example.com" \
--env "NTFY_TOPIC=backups" \
--env "NTY_TOKEN=tk_*****" \
ghcr.io/zekrotja/borgmatic-check
You can also use the provided docker-compose.yml file, if you prefer that.
Now you can schedule your checks with a task scheduler like cron, for example.