2017-06-29 01:12:49 +00:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
image_name=$1
|
|
|
|
tag=$2
|
|
|
|
|
|
|
|
full_image="${image_name}:${tag}"
|
|
|
|
container_name="${image_name}-${tag}"
|
|
|
|
|
2017-06-29 06:28:48 +00:00
|
|
|
# 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
|
2017-06-29 01:12:49 +00:00
|
|
|
docker exec $container_name sh -c "mkdir -p /data && echo Test > /data/test.txt"
|
2017-06-29 06:28:48 +00:00
|
|
|
# Backup data
|
|
|
|
echo "Making backup..."
|
2017-06-29 01:12:49 +00:00
|
|
|
docker exec $container_name /backup.sh
|
2017-06-29 06:28:48 +00:00
|
|
|
# Verify the backup
|
|
|
|
echo "Verify backup..."
|
2017-06-29 01:12:49 +00:00
|
|
|
docker exec $container_name /verify.sh
|
2017-06-29 06:28:48 +00:00
|
|
|
# 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
|
2017-06-29 01:12:49 +00:00
|
|
|
docker rm $container_name
|