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
|
|
|
|
|
|
|
case "$MODE" in
|
|
|
|
backup)
|
|
|
|
echo "Launched in backup mode, performing backup..." >> /dev/stderr
|
|
|
|
duplicity \
|
|
|
|
--allow-source-mismatch \
|
2023-05-17 12:33:44 +00:00
|
|
|
--full-if-older-than "${DUPLICITY_FULL_IF_OLDER_THAN}" \
|
2023-03-14 18:32:14 +00:00
|
|
|
/mnt \
|
2023-05-17 12:33:44 +00:00
|
|
|
"${DUPLICITY_TARGET_URL}"
|
2023-03-14 18:32:14 +00:00
|
|
|
;;
|
|
|
|
restore)
|
|
|
|
echo "Launched in restore mode, restoring backup..." >> /dev/stderr
|
|
|
|
duplicity \
|
|
|
|
--force \
|
|
|
|
--allow-source-mismatch \
|
2023-05-17 12:33:44 +00:00
|
|
|
"${DUPLICITY_TARGET_URL}" \
|
2023-03-14 18:32:14 +00:00
|
|
|
/mnt
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "No such mode." >> /dev/stderr
|
|
|
|
;;
|
|
|
|
esac
|