docker-volume-backup/docker-volume-recover.sh

21 lines
698 B
Bash
Raw Normal View History

2020-10-13 13:32:08 +02:00
#!/bin/bash
# @param $1 Volume-Name
2021-11-11 13:03:19 +01:00
# @param $2 Hash-Name
2020-10-13 13:32:08 +02:00
volume_name="$1"
2021-11-11 13:03:19 +01:00
backup_hash="$2"
backup_path="/Backups/$backup_hash/docker-volume-backup/latest/$volume_name/raw"
2021-11-11 13:17:02 +01:00
echo "Inspect volume $volume_name"
docker volume inspect "$volume_name"
exit_status_volume_inspect=$?
if [ $exit_status_volume_inspect -eq 0 ]; then
2021-11-11 13:03:19 +01:00
echo "Volume $volume_name allready exists"
else
echo "Create volume $volume_name"
docker volume create "$volume_name"
fi
if [ ! -d "$backup_path" ]; then
echo "ERROR: $backup_path doesn't exist"
exit 1
fi
docker run --rm -v "$volume_name:/recover/" -v "$backup_path:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"