From 20864164be1c1bc8e212f6577c7cac5a840550b5 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 1 Dec 2022 09:08:53 +0100 Subject: [PATCH] added gotify mess on error --- restic/files/backup.sh.jinja | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/restic/files/backup.sh.jinja b/restic/files/backup.sh.jinja index 07c48e0..044772d 100644 --- a/restic/files/backup.sh.jinja +++ b/restic/files/backup.sh.jinja @@ -6,6 +6,11 @@ export RESTIC_REPOSITORY="stfp:{{ pillar.restic.user }}@{{ pillar.restic.host }} {%- endif %} export RESTIC_PASSWORD={{ pillar.restic.password }} +GOTIFY_URL="{{ pillar.restic.gotify.url }}" +GOTIFY_TOKEN="{{ pillar.restic.gotify.token }}" +GOTIFY_PRIO="5" +GOTIFY_TITLE="backup on $HOSTNAME" + restic backup \ --exclude="*.tmp" \ --exclude="lost+found" \ @@ -49,3 +54,10 @@ restic backup \ /etc \ /root \ /home + +return_code="$?" +if [[ "$return_code" == "0" ]]; then + exit 0 +fi +MESSAGE="$(journalctl -u restic-backup.service -p 5 --since today)" +curl "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" -F "title=$GOTIFY_TITLE" -F "priority=$GOTIFY_PRIO" -F "message=$MESSAGE"