Added version

This commit is contained in:
Kevin Veen-Birkenbach 2022-09-01 07:43:08 +02:00
parent 16e1a76eef
commit f86727365d

View File

@ -1,10 +1,11 @@
#!/bin/bash
volume_name="$1" # Volume-Name
backup_hash="$2" # Hashed Machine ID
container="$3" # optional
password="$4" # optional
database="$5" # optional
backup_folder="Backups/$backup_hash/docker-volume-backup/latest/$volume_name"
version="$3" # version to backup
container="$4" # optional
mysql_root_password="$5" # optional
database="$6" # optional
backup_folder="Backups/$backup_hash/docker-volume-backup/versions/$version/$volume_name"
backup_files="/$backup_folder/files"
backup_sql="/$backup_folder/sql/backup.sql"
echo "Inspect volume $volume_name"
@ -21,6 +22,6 @@ if [ ! -d "$backup_files" ]; then
echo "ERROR: $backup_files and $backup_sql don't exist"
exit 1
fi
cat $backup_sql | docker exec -i $container /usr/bin/mysql -u root --password=$password $database
cat $backup_sql | docker exec -i "$container" '/usr/bin/mysql -u root --password="'$mysql_root_password'" "'$database'"'
fi
docker run --rm -v "$volume_name:/recover/" -v "$backup_files:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"