report backup status using apprise

This commit is contained in:
Pim Kunis 2023-05-10 18:54:43 +02:00
parent 50f2d0ada1
commit 15e8d14327
5 changed files with 40 additions and 17 deletions

View file

@ -42,6 +42,13 @@
cmd: ifup -a cmd: ifup -a
when: interfaces.changed when: interfaces.changed
- name: Delete externally managed environment file
shell:
cmd: "rm /usr/lib/python*/EXTERNALLY-MANAGED"
register: rm
changed_when: "rm.rc == 0"
failed_when: "false"
roles: roles:
- {role: ssh_ca_known_hosts, tags: ssh_ca_known_hosts} - {role: ssh_ca_known_hosts, tags: ssh_ca_known_hosts}
- {role: deploy_ssh_certificates, tags: deploy_ssh_certificates} - {role: deploy_ssh_certificates, tags: deploy_ssh_certificates}

View file

@ -1,16 +0,0 @@
location:
source_directories:
- /data
repositories:
- 'ssh://root@lewis.hyp/mnt/kingston1TB/hosts/{{ ansible_hostname }}'
retention:
keep_daily: 7
keep_weekly: 4
keep_monthly: 6
storage:
unknown_unencrypted_repo_access_is_ok: true
hooks:
before_everything:
- /root/stop_vms.sh
after_everything:
- /root/start_vms.sh

View file

@ -4,9 +4,13 @@
- borgbackup - borgbackup
- borgmatic - borgmatic
- name: Install apprise
pip:
name: apprise
- name: Copy Borgmatic script - name: Copy Borgmatic script
template: template:
src: "{{ role_path }}/files/backup.yml" src: "{{ role_path }}/templates/backup.yml.j2"
dest: /root/backup.yml dest: /root/backup.yml
- name: Copy start_vms.sh - name: Copy start_vms.sh

View file

@ -0,0 +1,27 @@
# vi: ft=yaml
location:
source_directories:
- /data
repositories:
- 'ssh://root@lewis.hyp/mnt/kingston1TB/hosts/{{ ansible_hostname }}'
retention:
keep_daily: 7
keep_weekly: 4
keep_monthly: 6
storage:
unknown_unencrypted_repo_access_is_ok: true
hooks:
before_everything:
- 'apprise --body="{{ ansible_hostname }}: Stopping VMs" {{ apprise_url }} || true'
- /root/stop_vms.sh
- 'apprise --body="{{ ansible_hostname }}: Stopped VMs" {{ apprise_url }} || true'
after_everything:
- 'apprise --body="{{ ansible_hostname }}: Starting VMs" {{ apprise_url }} || true'
- /root/start_vms.sh
- 'apprise --body="{{ ansible_hostname }}: Started VMs" {{ apprise_url }} || true'
before_backup:
- 'apprise --body="{{ ansible_hostname }}: Performing backup" {{ apprise_url }} || true'
after_backup:
- 'apprise --body="{{ ansible_hostname }}: Backup done" {{ apprise_url }} || true'
on_error:
- 'apprise --body="{{ ansible_hostname }}: Backup error" {{ apprise_url }} || true'

View file

@ -0,0 +1 @@
apprise_url: 'apprises://apprise.pim.kunis.nl:444/backups'