mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-25 17:51:03 +01:00
added database recovery
This commit is contained in:
parent
87a189efce
commit
6d6d7103d0
@ -1,9 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# @param $1 Volume-Name
|
volume_name="$1" # Volume-Name
|
||||||
# @param $2 Hash-Name
|
backup_hash="$2" # Hashed Machine ID
|
||||||
volume_name="$1"
|
container="$3" # optional
|
||||||
backup_hash="$2"
|
user="$4" # optional
|
||||||
backup_path="/Backups/$backup_hash/docker-volume-backup/latest/$volume_name/files"
|
password="$5" # optional
|
||||||
|
database="$6" # optional
|
||||||
|
backup_folder="Backups/$backup_hash/docker-volume-backup/latest/$volume_name"
|
||||||
|
backup_files="/$backup_folder/files"
|
||||||
|
backup_sql="/$backup_folder/sql/backup.sql"
|
||||||
echo "Inspect volume $volume_name"
|
echo "Inspect volume $volume_name"
|
||||||
docker volume inspect "$volume_name"
|
docker volume inspect "$volume_name"
|
||||||
exit_status_volume_inspect=$?
|
exit_status_volume_inspect=$?
|
||||||
@ -13,8 +17,11 @@ if [ $exit_status_volume_inspect -eq 0 ]; then
|
|||||||
echo "Create volume $volume_name"
|
echo "Create volume $volume_name"
|
||||||
docker volume create "$volume_name"
|
docker volume create "$volume_name"
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$backup_path" ]; then
|
if [ ! -d "$backup_files" ]; then
|
||||||
echo "ERROR: $backup_path doesn't exist"
|
if [ ! -f "$backup_sql" ]; then
|
||||||
|
echo "ERROR: $backup_files and $backup_sql don't exist"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
docker run --rm -v "$volume_name:/recover/" -v "$backup_path:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"
|
cat $backup_sql | docker exec -i $container /usr/bin/mysql -u $user --password=$password $database
|
||||||
|
fi
|
||||||
|
docker run --rm -v "$volume_name:/recover/" -v "$backup_files:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"
|
||||||
|
Loading…
Reference in New Issue
Block a user