mirror of
https://github.com/ViViDboarder/docker-duplicity-cron.git
synced 2024-12-03 17:26:46 +00:00
Add restore script and restore test
This commit is contained in:
parent
7dfaef9365
commit
b3ff6b6cce
@ -22,8 +22,9 @@ ENV PASSPHRASE="Correct.Horse.Battery.Staple"
|
||||
ENV CRON_SCHEDULE=""
|
||||
ENV VERIFY_CRON_SCHEDULE=""
|
||||
|
||||
ADD entrypoint.sh /
|
||||
ADD backup.sh /
|
||||
ADD entrypoint.sh /
|
||||
ADD restore.sh /
|
||||
ADD verify.sh /
|
||||
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
@ -21,8 +21,9 @@ ENV PASSPHRASE="Correct.Horse.Battery.Staple"
|
||||
ENV CRON_SCHEDULE=""
|
||||
ENV VERIFY_CRON_SCHEDULE=""
|
||||
|
||||
ADD entrypoint.sh /
|
||||
ADD backup.sh /
|
||||
ADD entrypoint.sh /
|
||||
ADD restore.sh /
|
||||
ADD verify.sh /
|
||||
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
@ -39,5 +39,5 @@ PATH_TO_BACKUP="/"
|
||||
Mount all volumes from your existing container with `--volumes-from` and then back up by providing the paths to those volumes. If there are more than one volumes, you'll want to use the above tip for mulitple backup sources
|
||||
|
||||
### To Do
|
||||
- [ ] Some easy way to trigger restoration
|
||||
- [x] Some easy way to trigger restoration (can now exec /restore.sh)
|
||||
- [ ] Automatic restoration if there is no source data
|
||||
|
@ -1,11 +1,6 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
# If key id is provied add arg
|
||||
if [ -e "$GPG_KEY_ID" ]; then
|
||||
OPT_ARGUMENTS="$OPT_ARGUMENTS --encrypt-sign-key=\"$GPG_KEY_ID\""
|
||||
fi
|
||||
|
||||
duplicity \
|
||||
--allow-source-mismatch \
|
||||
--asynchronous-upload \
|
||||
@ -18,5 +13,6 @@ duplicity \
|
||||
if [ -n "$CLEANUP_COMMAND" ]; then
|
||||
duplicity $CLEANUP_COMMAND \
|
||||
--log-file /root/duplicity.log \
|
||||
--name $BACKUP_NAME \
|
||||
$BACKUP_DEST
|
||||
fi
|
||||
|
@ -7,6 +7,11 @@ if [ "$1" == "bash" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# If key id is provied add arg
|
||||
if [ -e "$GPG_KEY_ID" ]; then
|
||||
OPT_ARGUMENTS="$OPT_ARGUMENTS --encrypt-sign-key=\"$GPG_KEY_ID\""
|
||||
fi
|
||||
|
||||
if [ "$SKIP_ON_START" != "true" ]; then
|
||||
/backup.sh
|
||||
fi
|
||||
|
10
restore.sh
Executable file
10
restore.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
duplicity restore \
|
||||
--log-file /root/duplicity.log \
|
||||
--name $BACKUP_NAME \
|
||||
$OPT_ARGUMENTS \
|
||||
$BACKUP_DEST \
|
||||
$PATH_TO_BACKUP
|
||||
|
22
test.sh
22
test.sh
@ -6,10 +6,26 @@ tag=$2
|
||||
full_image="${image_name}:${tag}"
|
||||
container_name="${image_name}-${tag}"
|
||||
|
||||
docker run -d -e CRON_SCHEDULE="0 0 12 1 1 ? *" -e SKIP_ON_START=true --name $container_name $full_image
|
||||
sleep 2
|
||||
# Create backup container
|
||||
docker run -d -e SKIP_ON_START=true --name ${container_name} $full_image bash -c "/bin/sleep 20"
|
||||
# Create some test data
|
||||
docker exec $container_name sh -c "mkdir -p /data && echo Test > /data/test.txt"
|
||||
# Backup data
|
||||
echo "Making backup..."
|
||||
docker exec $container_name /backup.sh
|
||||
# Verify the backup
|
||||
echo "Verify backup..."
|
||||
docker exec $container_name /verify.sh
|
||||
docker stop $container_name
|
||||
# Remove test file
|
||||
echo "Clear data..."
|
||||
docker exec $container_name sh -c "rm /data/*"
|
||||
# Restore the backup
|
||||
echo "Restore backup..."
|
||||
docker exec $container_name /restore.sh
|
||||
# Verify the backup
|
||||
echo "Verify backup..."
|
||||
docker exec $container_name /verify.sh
|
||||
# Stop the container
|
||||
docker kill $container_name
|
||||
# Remove the container
|
||||
docker rm $container_name
|
||||
|
Loading…
Reference in New Issue
Block a user