fix borg error not sending notification
This commit is contained in:
parent
62a47c1149
commit
fa95d94c0c
4 changed files with 17 additions and 3 deletions
9
ansible/roles/borg/backup-failure.service.j2
Normal file
9
ansible/roles/borg/backup-failure.service.j2
Normal 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
|
|
@ -1,5 +1,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup data using Borgmatic
|
Description=Backup data using Borgmatic
|
||||||
|
OnFailure=backup-failure.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/bin/borgmatic --config /root/backup.yml
|
ExecStart=/usr/bin/borgmatic --config /root/backup.yml
|
||||||
|
|
|
@ -17,6 +17,4 @@ hooks:
|
||||||
- guestunmount /mnt/thecloud && sleep 1
|
- guestunmount /mnt/thecloud && sleep 1
|
||||||
- virsh blockcommit tf-thecloud vdb --active --verbose --pivot
|
- virsh blockcommit tf-thecloud vdb --active --verbose --pivot
|
||||||
- rm /kvm/snapshots/thecloud.qcow2
|
- rm /kvm/snapshots/thecloud.qcow2
|
||||||
- apprise --body="Backup succeeded" {{ apprise_url }} || true
|
- apprise --body="Backup succeeded!" {{ apprise_url }} || true
|
||||||
on_error:
|
|
||||||
- apprise --body="Error while performing backup" {{ apprise_url }} || true
|
|
||||||
|
|
|
@ -35,6 +35,12 @@
|
||||||
dest: /etc/systemd/system/backup.timer
|
dest: /etc/systemd/system/backup.timer
|
||||||
notify: systemd daemon reload
|
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
|
- name: Enable backup timer
|
||||||
systemd:
|
systemd:
|
||||||
name: backup.timer
|
name: backup.timer
|
||||||
|
|
Reference in a new issue