mirror of
https://github.com/ViViDboarder/docker-restic-cron.git
synced 2024-11-21 12:46:36 +00:00
Add ability to auto restore
This commit is contained in:
parent
efb7d3e5ab
commit
e56e1a983a
@ -21,6 +21,7 @@ Mount any directories you'd like to back up as a volume and run
|
||||
|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|
|
||||
|PATH_TO_BACKUP|/data|The path to the directory you wish to backup. If you want to backup multiple, see the [tip below](#backing-up-more-than-one-source-directory)|
|
||||
|RESTORE_ON_EMPTY_START| |Set this to "true" and if the `$PATH_TO_BACKUP` is empty, it will restore the latest backup. This can be used for auto recovery from lost data|
|
||||
|SKIP_ON_START| |Skips backup on start if set to "true"|
|
||||
|VERIFY_CRON_SCHEDULE| |If you want to verify your backups on a schedule, provide it here|
|
||||
|
||||
|
@ -16,6 +16,12 @@ if [ -e "$GPG_KEY_ID" ]; then
|
||||
export OPT_ARGUMENTS="$OPT_ARGUMENTS --encrypt-sign-key=\"$GPG_KEY_ID\""
|
||||
fi
|
||||
|
||||
# If set to restore on start, restore if the data volume is empty
|
||||
if [ "$RESTORE_ON_EMPTY_START" == "true" -a -z "$(ls -A $PATH_TO_BACKUP)" ]; then
|
||||
/restore.sh
|
||||
fi
|
||||
|
||||
# Unless explicitly skipping, take a backup on startup
|
||||
if [ "$SKIP_ON_START" != "true" ]; then
|
||||
/backup.sh
|
||||
fi
|
||||
|
17
itest.sh
17
itest.sh
@ -19,13 +19,28 @@ echo "Verify backup..."
|
||||
echo "Delete test data..."
|
||||
rm -fr /data/*
|
||||
|
||||
echo "Verify deleted..."
|
||||
test -f /data/test.txt && exit 1 || echo "Gone"
|
||||
|
||||
echo "Restore backup..."
|
||||
/restore.sh
|
||||
|
||||
echo "Verify backup..."
|
||||
/verify.sh
|
||||
|
||||
echo "Verify incorrect passphrase fails..."
|
||||
echo "Delete test data again..."
|
||||
rm -fr /data/*
|
||||
|
||||
echo "Verify deleted..."
|
||||
test -f /data/test.txt && exit 1 || echo "Gone"
|
||||
|
||||
echo "Simulate a restart with RESTORE_ON_EMPTY_START..."
|
||||
RESTORE_ON_EMPTY_START=true /entrypoint.sh
|
||||
|
||||
echo "Verify restore happened..."
|
||||
test -f /data/test.txt
|
||||
|
||||
echo "Verify restore with incorrect passphrase fails..."
|
||||
export PASSPHRASE=Incorrect.Mule.Solar.Paperclip
|
||||
|
||||
echo "Fail to restore backup..."
|
||||
|
Loading…
Reference in New Issue
Block a user