dvbackup/test/test.sh

25 lines
792 B
Bash
Raw Normal View History

2022-08-30 22:26:52 +02:00
#!/usr/bin/env sh
cd "$(dirname "$0")" || exit 1
VOLUME_NAME="$(dd if=/dev/random bs=10 count=1 | base32)"
2022-08-30 22:26:52 +02:00
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 backup_all
2022-08-30 22:26:52 +02:00
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" DVB_I_KNOW_WHAT_I_DO=y \
../dvbackup restore_all "$VOLUME_NAME.tar" || exit 1
2022-08-30 22:26:52 +02:00
docker run --rm --volume="$VOLUME_NAME:/data" alpine \
sh -c 'stat /data/a.txt' || exit 1
2022-08-30 22:59:01 +02:00
2022-08-30 22:26:52 +02:00
exit 0