mirror of
https://github.com/offen/docker-volume-backup.git
synced 2026-01-06 15:42:37 +01:00
Fall back to default behavior when deployed to a worker node (#593)
* Add test demonstrating failure when running on worker node * Consider manager status when checking for swarm related features * Update documentation
This commit is contained in:
1
test/worker-node/.multinode
Normal file
1
test/worker-node/.multinode
Normal file
@@ -0,0 +1 @@
|
||||
worker1
|
||||
56
test/worker-node/docker-compose.yml
Normal file
56
test/worker-node/docker-compose.yml
Normal file
@@ -0,0 +1,56 @@
|
||||
services:
|
||||
database:
|
||||
image: mariadb:10.7
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == worker1
|
||||
environment:
|
||||
MARIADB_ROOT_PASSWORD: test
|
||||
MARIADB_DATABASE: backup
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -ptest --all-databases > /tmp/volume/dump.sql'
|
||||
- docker-volume-backup.copy-post=/bin/sh -c 'echo "post" > /tmp/volume/post.txt'
|
||||
- docker-volume-backup.stop-during-backup=true
|
||||
volumes:
|
||||
- app_data:/tmp/volume
|
||||
|
||||
other_database:
|
||||
image: mariadb:10.7
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == manager
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
environment:
|
||||
MARIADB_ROOT_PASSWORD: test
|
||||
MARIADB_DATABASE: backup
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre=touch /tmp/volume/not-relevant.txt
|
||||
- docker-volume-backup.exec-label=not-relevant
|
||||
volumes:
|
||||
- app_data:/tmp/volume
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
placement:
|
||||
constraints:
|
||||
- node.hostname == worker1
|
||||
environment:
|
||||
BACKUP_FILENAME: test.tar.gz
|
||||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||
EXEC_FORWARD_OUTPUT: "true"
|
||||
volumes:
|
||||
- backup_archive:/archive
|
||||
- app_data:/backup/data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
|
||||
volumes:
|
||||
app_data:
|
||||
backup_archive:
|
||||
33
test/worker-node/run.sh
Executable file
33
test/worker-node/run.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
export TMP_DIR=$(mktemp -d)
|
||||
export LOCAL_DIR=$(mktemp -d)
|
||||
|
||||
while [ -z $(docker ps -q -f name=backup) ]; do
|
||||
info "Backup container not ready yet. Retrying."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
sleep 20
|
||||
|
||||
docker exec $(docker ps -q -f name=backup) backup
|
||||
|
||||
mkdir -p /archive
|
||||
docker cp $(docker ps -q -f name=backup):/archive $LOCAL_DIR
|
||||
|
||||
tar -xvf "$LOCAL_DIR/archive/test.tar.gz" -C $TMP_DIR
|
||||
if [ ! -f "$TMP_DIR/backup/data/dump.sql" ]; then
|
||||
fail "Could not find file written by pre command."
|
||||
fi
|
||||
pass "Found expected file."
|
||||
|
||||
if [ -f "$TMP_DIR/backup/data/post.txt" ]; then
|
||||
fail "File created in post command was present in backup."
|
||||
fi
|
||||
pass "Did not find unexpected file."
|
||||
Reference in New Issue
Block a user