borgmatic integration for matrix-webhook-bridge
Example files for integrating borgmatic with matrix-webhook-bridge.
The script is invoked by borgmatic's after_backup and on_error hooks and sends a formatted
Matrix message indicating whether the backup completed successfully or failed, including the
hostname it ran on.
Assumptions
matrix-webhook-bridgeis reachable athttp://localhost:5001(configurable viaMATRIX_WEBHOOK_BRIDGE_URL).- If
server.webhook_secretis set on the bridge, pointBRIDGE_CONFIGat the config file so the script reads the secret automatically (requirespyyaml). Alternatively, exportWEBHOOK_SECRETdirectly. - borgmatic is installed and configured on the host.
Add a Matrix Application Service
Follow the instructions in the Matrix Application Service Setup guide to set up a Matrix Application Service for borgmatic and invite the bot user to a room on your Synapse server.
Setup
Copy the notify.py script to /etc/borgmatic/hooks and make it executable:
mkdir -p /etc/borgmatic/hooks
curl \
-L https://raw.githubusercontent.com/krahlos/matrix-webhook-bridge/main/integrations/borgmatic/notify.py \
-o /etc/borgmatic/hooks/notify.py
chmod +x /etc/borgmatic/hooks/notify.py
Example Notifications
On success:
On failure:
Configuration
Add the hook to the after_backup and on_error sections of your /etc/borgmatic.d/config.yaml: