diff --git a/restic/files/backup.sh.jinja b/restic/files/backup.sh.jinja index 40eba42..28ab55a 100644 --- a/restic/files/backup.sh.jinja +++ b/restic/files/backup.sh.jinja @@ -2,6 +2,10 @@ {%- if pillar['pods']['mariadb'] is defined %} umask 0077 +GOTIFY_URL="{{ pillar.restic.gotify.url }}" +GOTIFY_TITLE="$(hostname)" +GOTIFY_TOKEN="{{ pillar.restic.gotify.token }}" +GOTIFY_PRIO="5" BACKUP_DIR={{ pillar.pods.mariadb.containers.main.backup_dir }} databases=$(podman exec -it mariadb-main mariadb -B -u root -p{{ pillar.pods.mariadb.containers.main.env.MYSQL_ROOT_PASSWORD }} -e "SHOW DATABASES;" | tr -d "| " | grep -v Database) @@ -84,11 +88,17 @@ podman run --rm \ return_code=$? + {%- if pillar['containers']['freeipa'] is defined %} echo "Starting FreeIPA" systemctl start freeipa.service {%- endif %} +MESSAGE="$(journalctl -u restic-backup.service --since today | grep Error)" +if [[ "$MESSAGE" != "-- No entries --" ]]; then + curl "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" -F "title=$GOTIFY_TITLE" -F "priority=$GOTIFY_PRIO" -F "message=$MESSAGE" +fi + if [[ $return_code -eq 0 ]]; then exit 0 fi