mirror of
https://github.com/Steffo99/backup-duplicity.git
synced 2025-02-16 21:34:03 +00:00
Compare commits
10 commits
05e956698f
...
38756cc76d
Author | SHA1 | Date | |
---|---|---|---|
38756cc76d | |||
278202ac00 | |||
0ffa37d684 | |||
61cd250c56 | |||
8b84ddac34 | |||
7764fa245b | |||
3e231cdbf0 | |||
5519009a2f | |||
b2f7fc8058 | |||
d07d328193 |
4 changed files with 41 additions and 15 deletions
18
Dockerfile
18
Dockerfile
|
@ -9,23 +9,27 @@ RUN pip install --upgrade pip --break-system-packages
|
|||
RUN pip install google-auth-oauthlib google-api-python-client --break-system-packages
|
||||
RUN apk del rust musl-dev libffi-dev gcc python3-dev cargo git pkgconfig openssl-dev
|
||||
|
||||
WORKDIR /usr/lib/duplicity
|
||||
ENV HOME="/usr/lib/duplicity"
|
||||
# Create log directory
|
||||
RUN mkdir --parents --verbose /var/log/gestalt-amadeus
|
||||
|
||||
# Create program directory
|
||||
WORKDIR /usr/lib/gestalt-amadeus
|
||||
ENV HOME="/usr/lib/gestalt-amadeus"
|
||||
|
||||
# Add entrypoint
|
||||
COPY ./entrypoint.sh /usr/lib/backup-duplicity/entrypoint.sh
|
||||
COPY ./restore.sh /usr/lib/backup-duplicity/restore.sh
|
||||
COPY ./entrypoint.sh /usr/lib/gestalt-amadeus/entrypoint.sh
|
||||
COPY ./restore.sh /usr/lib/gestalt-amadeus/restore.sh
|
||||
COPY ./backup.sh /etc/periodic/daily/backup.sh
|
||||
|
||||
# Configure entrypoint and command
|
||||
ENTRYPOINT ["/usr/lib/backup-duplicity/entrypoint.sh"]
|
||||
ENTRYPOINT ["/usr/lib/gestalt-amadeus/entrypoint.sh"]
|
||||
CMD []
|
||||
|
||||
# Add image labels
|
||||
LABEL org.opencontainers.image.title="backup-duplicity"
|
||||
LABEL org.opencontainers.image.title="gestalt-amadeus"
|
||||
LABEL org.opencontainers.image.description="Backup solution for Docker volumes based on Duplicity"
|
||||
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
|
||||
LABEL org.opencontainers.image.url="https://github.com/Steffo99/docker-backup-duplicity"
|
||||
LABEL org.opencontainers.image.url="https://github.com/Steffo99/gestalt-amadeus"
|
||||
LABEL org.opencontainers.image.authors="Stefano Pigozzi <me@steffo.eu>"
|
||||
|
||||
# Configure duplicity
|
||||
|
|
18
backup.sh
18
backup.sh
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
hostname=$(cat /etc/hostname)
|
||||
|
||||
|
@ -28,8 +28,10 @@ duplicity \
|
|||
backup \
|
||||
--allow-source-mismatch \
|
||||
--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=$?
|
||||
|
||||
|
@ -37,23 +39,27 @@ if [ -n "${NTFY}" ]; then
|
|||
case "$backup_result" in
|
||||
0)
|
||||
echo "Sending ntfy backup complete notification..." >> /dev/stderr
|
||||
backup_summary=$(grep -F -A '16' -e '--------------[ Backup Statistics ]--------------' "/var/log/gestalt-amadeus/log.txt")
|
||||
ntfy_message=$(printf "Duplicity has successfully performed a backup to **%s**!\n\n\`\`\`\n%s\n\`\`\`" "$DUPLICITY_TARGET_URL" "$backup_summary")
|
||||
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,duplicity,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "X-Tags: white_check_mark,gestalt-amadeus,gestalt-amadeus-backup,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "Content-Type: text/markdown" \
|
||||
>/dev/null
|
||||
;;
|
||||
*)
|
||||
echo "Sending ntfy backup failed notification..." >> /dev/stderr
|
||||
backup_log=$(cat "/var/log/gestalt-amadeus/log.txt")
|
||||
ntfy_message=$(printf "Duplicity has failed to perform a backup to **%s**.\n\n\`\`\`\n%s\n\`\`\`" "$DUPLICITY_TARGET_URL" "$backup_log")
|
||||
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,duplicity,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "X-Tags: sos,gestalt-amadeus,gestalt-amadeus-backup,container-${hostname},${NTFY_TAGS}" \
|
||||
--header "Content-Type: text/markdown" \
|
||||
>/dev/null
|
||||
;;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Selected mode: $MODE"
|
||||
|
||||
case "$MODE" in
|
||||
backup)
|
||||
echo "Running first backup..."
|
||||
|
|
18
restore.sh
18
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
|
||||
|
@ -12,5 +12,19 @@ duplicity \
|
|||
restore \
|
||||
--force \
|
||||
--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 **%s**!" "${DUPLICITY_TARGET_URL}")
|
||||
|
||||
curl "${NTFY}" \
|
||||
--silent \
|
||||
--header "X-Title: Restore complete" \
|
||||
--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" \
|
||||
>/dev/null
|
||||
|
|
Loading…
Add table
Reference in a new issue