fix borg error not sending notification

This commit is contained in:
Pim Kunis 2023-08-08 11:38:05 +02:00
parent 62a47c1149
commit fa95d94c0c
4 changed files with 17 additions and 3 deletions

View file

@ -0,0 +1,9 @@
[Unit]
Description=Send backup failure notification
[Service]
Type=oneshot
ExecStart=apprise --body="Failed to create backup!" {{ apprise_url }}
[Install]
WantedBy=multi-user.target

View file

@ -1,5 +1,6 @@
[Unit]
Description=Backup data using Borgmatic
OnFailure=backup-failure.service
[Service]
ExecStart=/usr/bin/borgmatic --config /root/backup.yml

View file

@ -17,6 +17,4 @@ hooks:
- guestunmount /mnt/thecloud && sleep 1
- virsh blockcommit tf-thecloud vdb --active --verbose --pivot
- rm /kvm/snapshots/thecloud.qcow2
- apprise --body="Backup succeeded" {{ apprise_url }} || true
on_error:
- apprise --body="Error while performing backup" {{ apprise_url }} || true
- apprise --body="Backup succeeded!" {{ apprise_url }} || true

View file

@ -35,6 +35,12 @@
dest: /etc/systemd/system/backup.timer
notify: systemd daemon reload
- name: Copy systemd backup failure service
template:
src: "{{ role_path }}/backup-failure.service.j2"
dest: /etc/systemd/system/backup-failure.service
notify: systemd daemon reload
- name: Enable backup timer
systemd:
name: backup.timer