You've already forked docker-volume-backup
mirror of
https://github.com/offen/docker-volume-backup.git
synced 2025-11-23 21:44:40 +02:00
Possibility to use -u (user) option in docker exec (#203)
* Add user option for docker exec * Add test for user option * Return test version for image * remove gitea config file * refactor tests * remove comments & fix image name * add docs * cleanup * Update README.md with suggested correction Co-authored-by: Frederik Ring <frederik.ring@gmail.com> * fix backup command & bind folder instead of volume --------- Co-authored-by: tao <generaltao.md@gmail.com> Co-authored-by: Frederik Ring <frederik.ring@gmail.com>
This commit is contained in:
2
test/user/.gitignore
vendored
Normal file
2
test/user/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
local
|
||||
backup
|
||||
30
test/user/docker-compose.yml
Normal file
30
test/user/docker-compose.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
version: '2.4'
|
||||
|
||||
services:
|
||||
alpine:
|
||||
image: alpine:3.17.3
|
||||
tty: true
|
||||
volumes:
|
||||
- app_data:/tmp
|
||||
labels:
|
||||
- docker-volume-backup.archive-pre.user=testuser
|
||||
- docker-volume-backup.archive-pre=/bin/sh -c 'whoami > /tmp/whoami.txt'
|
||||
|
||||
|
||||
backup:
|
||||
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
environment:
|
||||
BACKUP_FILENAME: test.tar.gz
|
||||
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
|
||||
EXEC_FORWARD_OUTPUT: "true"
|
||||
volumes:
|
||||
- ./local:/archive
|
||||
- app_data:/backup/data:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
|
||||
volumes:
|
||||
app_data:
|
||||
archive:
|
||||
30
test/user/run.sh
Normal file
30
test/user/run.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
. ../util.sh
|
||||
current_test=$(basename $(pwd))
|
||||
|
||||
docker compose up -d
|
||||
|
||||
user_name=testuser
|
||||
docker exec user-alpine-1 adduser --disabled-password "$user_name"
|
||||
|
||||
docker compose exec backup backup
|
||||
|
||||
tar -xvf ./local/test.tar.gz
|
||||
if [ ! -f ./backup/data/whoami.txt ]; then
|
||||
fail "Could not find file written by pre command."
|
||||
fi
|
||||
pass "Found expected file."
|
||||
|
||||
tar -xvf ./local/test.tar.gz
|
||||
if [ "$(cat ./backup/data/whoami.txt)" != "$user_name" ]; then
|
||||
fail "Could not find expected user name."
|
||||
fi
|
||||
pass "Found expected user."
|
||||
|
||||
docker compose down --volumes
|
||||
sudo rm -rf ./local
|
||||
|
||||
Reference in New Issue
Block a user