mirror of
https://github.com/Steffo99/backup-duplicity.git
synced 2025-02-16 21:34:03 +00:00
Append logs to ntfy message
This commit is contained in:
parent
8b84ddac34
commit
61cd250c56
2 changed files with 14 additions and 7 deletions
11
backup.sh
11
backup.sh
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
hostname=$(cat /etc/hostname)
|
||||
|
||||
|
@ -30,7 +30,8 @@ duplicity \
|
|||
--full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \
|
||||
--verbosity info \
|
||||
/mnt \
|
||||
"${DUPLICITY_TARGET_URL}"
|
||||
"${DUPLICITY_TARGET_URL}" \
|
||||
| tee "/var/log/gestalt-amadeus/log.txt"
|
||||
|
||||
backup_result=$?
|
||||
|
||||
|
@ -38,10 +39,11 @@ if [ -n "${NTFY}" ]; then
|
|||
case "$backup_result" in
|
||||
0)
|
||||
echo "Sending ntfy backup complete notification..." >> /dev/stderr
|
||||
ntfy_message=$(printf "Duplicity has successfully performed a backup to **${DUPLICITY_TARGET_URL}**!\n\n```\n")$(cat "/var/log/gestalt-amadeus/log.txt")$(printf "\n```")
|
||||
curl "${NTFY}" \
|
||||
--silent \
|
||||
--header "X-Title: Backup complete" \
|
||||
--data "Duplicity has successfully performed a backup to **${DUPLICITY_TARGET_URL}**!" \
|
||||
--data "$ntfy_message" \
|
||||
--header "X-Priority: low" \
|
||||
--header "X-Tags: white_check_mark,gestalt-amadeus,gestalt-amadeus-backup,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "Content-Type: text/markdown" \
|
||||
|
@ -49,10 +51,11 @@ if [ -n "${NTFY}" ]; then
|
|||
;;
|
||||
*)
|
||||
echo "Sending ntfy backup failed notification..." >> /dev/stderr
|
||||
ntfy_message=$(printf "Duplicity failed to perform a backup to **${DUPLICITY_TARGET_URL}**, and exited with status code **${backup_result}**.\n\n```\n")$(cat "/var/log/gestalt-amadeus/log.txt")$(printf "\n```")
|
||||
curl "${NTFY}" \
|
||||
--silent \
|
||||
--header "X-Title: Backup failed" \
|
||||
--data "Duplicity failed to perform a backup to **${DUPLICITY_TARGET_URL}**, and exited with status code **${backup_result}**." \
|
||||
--data "$ntfy_message" \
|
||||
--header "X-Priority: max" \
|
||||
--header "X-Tags: sos,gestalt-amadeus,gestalt-amadeus-backup,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "Content-Type: text/markdown" \
|
||||
|
|
10
restore.sh
10
restore.sh
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# Get secrets from files
|
||||
# Insecure, but there's not much I can do about it
|
||||
|
@ -14,12 +14,16 @@ duplicity \
|
|||
--allow-source-mismatch \
|
||||
--verbosity info \
|
||||
"${DUPLICITY_TARGET_URL}" \
|
||||
/mnt
|
||||
/mnt \
|
||||
| tee "/var/log/gestalt-amadeus/log.txt"
|
||||
|
||||
|
||||
ntfy_message=$(printf "Duplicity has successfully restored a backup from **${DUPLICITY_TARGET_URL}**!\n\n```\n")$(cat "/var/log/gestalt-amadeus/log.txt")$(printf "\n```")
|
||||
|
||||
curl "${NTFY}" \
|
||||
--silent \
|
||||
--header "X-Title: Restore complete" \
|
||||
--data "Duplicity has successfully restored a backup from **${DUPLICITY_TARGET_URL}**!" \
|
||||
--data "$ntfy_message" \
|
||||
--header "X-Priority: low" \
|
||||
--header "X-Tags: white_check_mark,gestalt-amadeus,gestalt-amadeus-restore,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "Content-Type: text/markdown" \
|
||||
|
|
Loading…
Add table
Reference in a new issue