add systemd timer for backups

This commit is contained in:
nd 2021-03-14 00:02:06 +01:00
parent baa9bd7bed
commit 6c214a2330
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9
6 changed files with 59 additions and 0 deletions

4
templates/status-email-root.j2 Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
set -euo pipefail
systemctl status "$1" | mail -s "service $1 failed on $( hostname )" root || true

View file

@ -0,0 +1,7 @@
[Unit]
Description=Send a mail to root in case of a service failure
[Service]
Type=oneshot
ExecStart=/usr/local/bin/status-email-root %i

11
templates/timer.j2 Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=Execute backup job
[Timer]
Persistent=true
{% if "OnCalendar" in backups.jobs[item] %}
OnCalendar={{ backups.jobs[item].OnCalendar }}
{% endif %}
[Install]
WantedBy=timers.target