24 lines
773 B
Bash
24 lines
773 B
Bash
|
#!/usr/bin/env sh
|
||
|
|
||
|
|
||
|
cd "$(dirname "$0")" || exit 1
|
||
|
|
||
|
VOLUME_NAME="$(dd if=/dev/random bs=6 count=1 | base64)"
|
||
|
docker volume create "$VOLUME_NAME"
|
||
|
|
||
|
# shellcheck disable=SC2064
|
||
|
trap "docker volume rm $VOLUME_NAME && rm -f $VOLUME_NAME.tar" EXIT
|
||
|
|
||
|
docker run --rm --volume="$VOLUME_NAME:/data" alpine \
|
||
|
sh -c 'echo "test" > /data/a.txt'
|
||
|
DOCKER=./mock-docker.sh DOCKER_MOCK_VOLUME="$VOLUME_NAME" \
|
||
|
../dvbackup.sh backup_all
|
||
|
stat "$VOLUME_NAME.tar" || exit 1
|
||
|
docker run --rm --volume="$VOLUME_NAME:/data" alpine \
|
||
|
sh -c 'rm /data/a.txt' || exit 1
|
||
|
DOCKER=./mock-docker.sh DOCKER_MOCK_VOLUME="$VOLUME_NAME" \
|
||
|
../dvbackup.sh restore_all "$VOLUME_NAME.tar" || exit 1
|
||
|
docker run --rm --volume="$VOLUME_NAME:/data" alpine \
|
||
|
sh -c 'stat /data/a.txt' || exit 1
|
||
|
exit 0
|