Optimized performance of backup script

This commit is contained in:
Kevin Veen-Birkenbach 2021-11-11 13:03:19 +01:00
parent f23ea7e6d3
commit 568888952f

View File

@ -1,6 +1,17 @@
#!/bin/bash
# @param $1 Volume-Name
# @param $2 Hash-Name
volume_name="$1"
backup_path="$2"
docker volume create "$volume_name"
docker run --rm -v "$volume_name:/recover/" -v "$backup_path:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv /backup/ /recover/"
backup_hash="$2"
backup_path="/Backups/$backup_hash/docker-volume-backup/latest/$volume_name"
if docker volume inspect; then
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/"