2022-02-22 07:49:24 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# This test refers to https://github.com/offen/docker-volume-backup/issues/71
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
2022-06-23 14:40:29 +02:00
|
|
|
. ../util.sh
|
|
|
|
current_test=$(basename $(pwd))
|
2022-02-22 07:49:24 +01:00
|
|
|
|
|
|
|
mkdir -p local
|
|
|
|
|
|
|
|
docker-compose up -d
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
docker-compose exec backup backup
|
|
|
|
|
2022-06-23 14:40:29 +02:00
|
|
|
tmp_dir=$(mktemp -d)
|
|
|
|
sudo tar --same-owner -xvf ./local/backup.tar.gz -C $tmp_dir
|
2022-02-22 07:49:24 +01:00
|
|
|
|
2022-06-23 14:40:29 +02:00
|
|
|
sudo find $tmp_dir/backup/postgres > /dev/null
|
|
|
|
pass "Backup contains files at expected location"
|
2022-02-22 07:49:24 +01:00
|
|
|
|
2022-06-23 14:40:29 +02:00
|
|
|
for file in $(sudo find $tmp_dir/backup/postgres); do
|
2022-02-22 07:49:24 +01:00
|
|
|
if [ "$(sudo stat -c '%u:%g' $file)" != "70:70" ]; then
|
2022-06-23 14:40:29 +02:00
|
|
|
fail "Unexpected file ownership for $file: $(sudo stat -c '%u:%g' $file)"
|
2022-02-22 07:49:24 +01:00
|
|
|
fi
|
|
|
|
done
|
2022-06-23 14:40:29 +02:00
|
|
|
pass "All files and directories in backup preserved their ownership."
|
2022-02-22 07:49:24 +01:00
|
|
|
|
|
|
|
docker-compose down --volumes
|