From 917a4577c5582099a39c806db175a270fd599db7 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Sun, 30 Jul 2017 12:18:12 -0700 Subject: [PATCH] Add schedule for full backups and restore args --- Dockerfile.raspbian | 1 + Dockerfile.ubuntu | 1 + Makefile | 4 +++- Readme.md | 3 ++- backup.sh | 1 + entrypoint.sh | 5 +++++ restore.sh | 2 +- 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile.raspbian b/Dockerfile.raspbian index 084b596..f91a65e 100644 --- a/Dockerfile.raspbian +++ b/Dockerfile.raspbian @@ -20,6 +20,7 @@ ENV PASSPHRASE="Correct.Horse.Battery.Staple" # Cron schedules ENV CRON_SCHEDULE="" +ENV FULL_CRON_SCHEDULE="" ENV VERIFY_CRON_SCHEDULE="" ADD backup.sh / diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index 7503c9b..fbe141f 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -19,6 +19,7 @@ ENV PASSPHRASE="Correct.Horse.Battery.Staple" # Cron schedules ENV CRON_SCHEDULE="" +ENV FULL_CRON_SCHEDULE="" ENV VERIFY_CRON_SCHEDULE="" ADD backup.sh / diff --git a/Makefile b/Makefile index 210871d..5456c37 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ -.PHONY: build-x86 build-arm build-all +.PHONY: build-x86 build-arm build-all test DOCKER_TAG ?= docker-duplicity-cron default: build-x86 +test: test-x86 + build-x86: docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu . diff --git a/Readme.md b/Readme.md index e553875..fc7db28 100644 --- a/Readme.md +++ b/Readme.md @@ -12,8 +12,9 @@ Mount any directories you'd like to back up as a volume and run |BACKUP_DEST|file:///backups|Destination to store backups (See [duplicity documenation](http://duplicity.nongnu.org/duplicity.1.html#sect7))| |BACKUP_NAME|backup|What the name for the backup should be. If using a single store for multiple backups, make sure this is unique| |CLEANUP_COMMAND| |An optional duplicity command to execute after backups to clean older ones out (eg. "remove-all-but-n-full 2")| -|CRON_SCHEDULE| |If you want to backup on a schedule, provide it here. By default we just backup once and exit| +|CRON_SCHEDULE| |If you want to periodic incremental backups on a schedule, provide it here. By default we just backup once and exit| |FTP_PASSWORD| |Used to provide passwords for some backends. May not work without an attached TTY| +|FULL_CRON_SCHEDULE| |If you want to periodic full backups on a schedule, provide it here. This requires an incremental cron schedule too.| |GPG_KEY_ID| |The ID of the key you wish to use. See [Encryption](#encryption) section below| |OPT_ARGUMENTS| |Any additional arguments to provide to the duplicity backup command. These can also be provided as additional arguments via the command line| |PASSPHRASE|Correct.Horse.Battery.Staple|Passphrase to use for GPG| diff --git a/backup.sh b/backup.sh index f2f6fc5..b062349 100755 --- a/backup.sh +++ b/backup.sh @@ -2,6 +2,7 @@ set -e duplicity \ + $1 \ --asynchronous-upload \ --log-file /root/duplicity.log \ --name $BACKUP_NAME \ diff --git a/entrypoint.sh b/entrypoint.sh index c3c62e2..9b872f1 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,6 +33,11 @@ if [ -n "$CRON_SCHEDULE" ]; then echo "$CRON_SCHEDULE source /env.sh && /backup.sh 2>> /cron.log" >> /crontab.conf echo "Backups scheduled as $CRON_SCHEDULE" + if [ -n "$FULL_CRON_SCHEDULE" ]; then + echo "$FULL_CRON_SCHEDULE source /env.sh && /backup.sh full 2>> /cron.log" >> /crontab.conf + echo "Full backup scheduled as $VERIFY_CRON_SCHEDULE" + fi + if [ -n "$VERIFY_CRON_SCHEDULE" ]; then echo "$VERIFY_CRON_SCHEDULE source /env.sh && /verify.sh 2>> /cron.log" >> /crontab.conf echo "Verify scheduled as $VERIFY_CRON_SCHEDULE" diff --git a/restore.sh b/restore.sh index 16a0bcd..d31ec25 100755 --- a/restore.sh +++ b/restore.sh @@ -6,6 +6,6 @@ duplicity restore \ --log-file /root/duplicity.log \ --name $BACKUP_NAME \ $OPT_ARGUMENTS \ + $@ \ $BACKUP_DEST \ $PATH_TO_BACKUP -