2021-07-11 13:27:01 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
2022-06-23 14:40:29 +02:00
|
|
|
. ../util.sh
|
|
|
|
current_test=$(basename $(pwd))
|
2021-07-11 13:27:01 +02:00
|
|
|
|
|
|
|
docker network create test_network
|
|
|
|
docker volume create backup_data
|
|
|
|
docker volume create app_data
|
2022-02-13 09:41:36 +01:00
|
|
|
# This volume is created to test whether empty directories are handled
|
|
|
|
# correctly. It is not supposed to hold any data.
|
2021-12-29 10:10:12 +01:00
|
|
|
docker volume create empty_data
|
2021-07-11 13:27:01 +02:00
|
|
|
|
|
|
|
docker run -d \
|
|
|
|
--name minio \
|
|
|
|
--network test_network \
|
|
|
|
--env MINIO_ROOT_USER=test \
|
|
|
|
--env MINIO_ROOT_PASSWORD=test \
|
|
|
|
--env MINIO_ACCESS_KEY=test \
|
|
|
|
--env MINIO_SECRET_KEY=GMusLtUmILge2by+z890kQ \
|
|
|
|
-v backup_data:/data \
|
|
|
|
minio/minio:RELEASE.2020-08-04T23-10-51Z server /data
|
|
|
|
|
|
|
|
docker exec minio mkdir -p /data/backup
|
|
|
|
|
|
|
|
docker run -d \
|
|
|
|
--name offen \
|
|
|
|
--network test_network \
|
|
|
|
-v app_data:/var/opt/offen/ \
|
|
|
|
offen/offen:latest
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
|
2021-09-11 10:30:36 +02:00
|
|
|
docker run --rm \
|
2021-07-11 13:27:01 +02:00
|
|
|
--network test_network \
|
|
|
|
-v app_data:/backup/app_data \
|
2021-12-29 10:10:12 +01:00
|
|
|
-v empty_data:/backup/empty_data \
|
2021-07-11 13:27:01 +02:00
|
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
|
|
--env AWS_ACCESS_KEY_ID=test \
|
|
|
|
--env AWS_SECRET_ACCESS_KEY=GMusLtUmILge2by+z890kQ \
|
|
|
|
--env AWS_ENDPOINT=minio:9000 \
|
|
|
|
--env AWS_ENDPOINT_PROTO=http \
|
|
|
|
--env AWS_S3_BUCKET_NAME=backup \
|
|
|
|
--env BACKUP_FILENAME=test.tar.gz \
|
2021-11-08 08:44:59 +01:00
|
|
|
--env "BACKUP_FROM_SNAPSHOT=true" \
|
2021-09-11 10:30:36 +02:00
|
|
|
--entrypoint backup \
|
2022-02-22 07:53:33 +01:00
|
|
|
offen/docker-volume-backup:${TEST_VERSION:-canary}
|
2021-07-11 13:27:01 +02:00
|
|
|
|
2023-03-16 19:32:44 +01:00
|
|
|
docker run --rm \
|
2021-07-11 13:27:01 +02:00
|
|
|
-v backup_data:/data alpine \
|
2021-12-29 10:10:12 +01:00
|
|
|
ash -c 'tar -xvf /data/backup/test.tar.gz && test -f /backup/app_data/offen.db && test -d /backup/empty_data'
|
2021-07-11 13:27:01 +02:00
|
|
|
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "Found relevant files in untared remote backup."
|
2021-07-11 13:27:01 +02:00
|
|
|
|
2022-02-13 09:41:36 +01:00
|
|
|
# This test does not stop containers during backup. This is happening on
|
|
|
|
# purpose in order to cover this setup as well.
|
2022-06-23 14:40:29 +02:00
|
|
|
expect_running_containers "2"
|
2021-07-11 13:27:01 +02:00
|
|
|
|
2021-11-08 08:44:59 +01:00
|
|
|
docker rm $(docker stop minio offen)
|
2021-07-11 13:27:01 +02:00
|
|
|
docker volume rm backup_data app_data
|
|
|
|
docker network rm test_network
|