1
Fork 0
mirror of https://github.com/Steffo99/backup-duplicity.git synced 2024-12-22 03:34:17 +00:00
gestalt-amadeus/backup.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2023-03-14 18:32:14 +00:00
#!/bin/sh
set -e
# Get secrets from files
# Insecure, but there's not much I can do about it
# It's duplicity's fault!
2023-05-17 12:33:44 +00:00
export PASSPHRASE=$(cat "${DUPLICITY_PASSPHRASE_FILE}")
2023-03-14 18:32:14 +00:00
2023-05-17 12:36:47 +00:00
echo "Launched in backup mode, performing backup..." >> /dev/stderr
2024-10-24 08:38:59 +00:00
if [ -n "${NTFY}" ]; then
echo "Sending ntfy backup start notification..." >> /dev/stderr
curl "${NTFY}" \
--silent \
--header "X-Title: Backup started" \
--data "Duplicity is attempting to perform a backup to **${DUPLICITY_TARGET_URL}**..." \
--header "X-Priority: min" \
--header "X-Tags: arrow_heading_up,${NTFY_TAGS}" \
--header "Content-Type: text/markdown"
fi
2023-05-17 12:36:47 +00:00
duplicity \
2024-10-25 01:09:24 +00:00
backup \
2024-10-24 08:38:59 +00:00
--allow-source-mismatch \
--full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \
/mnt \
"${DUPLICITY_TARGET_URL}"
backup_result=$?
if [ -n "${NTFY}" ]; then
case "$backup_result" in
0)
echo "Sending ntfy backup complete notification..." >> /dev/stderr
curl "${NTFY}" \
--silent \
--header "X-Title: Backup complete" \
--data "Duplicity has successfully performed a backup to **${DUPLICITY_TARGET_URL}**!" \
--header "X-Priority: low" \
--header "X-Tags: white_check_mark,${NTFY_TAGS}" \
--header "Content-Type: text/markdown"
;;
*)
echo "Sending ntfy backup failed notification..." >> /dev/stderr
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}**." \
--header "X-Priority: max" \
--header "X-Tags: sos,${NTFY_TAGS}" \
--header "Content-Type: text/markdown"
;;
esac
fi