mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-10-31 23:33:11 +01:00
Solved bug in recovery logic
This commit is contained in:
parent
0f2ef55f1e
commit
18fcd3b06d
@ -17,11 +17,16 @@ 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_files" ]; then
|
|
||||||
if [ ! -f "$backup_sql" ]; then
|
if [ -f "$backup_sql" ]; then
|
||||||
echo "ERROR: $backup_files and $backup_sql don't exist"
|
echo "recover mysql dump"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
cat $backup_sql | docker exec -i "$container" '/usr/bin/mysql -u root --password="'$mysql_root_password'" "'$database'"'
|
cat $backup_sql | docker exec -i "$container" '/usr/bin/mysql -u root --password="'$mysql_root_password'" "'$database'"'
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
if [ -d "$backup_files" ]; then
|
||||||
|
echo "recover files"
|
||||||
|
docker run --rm -v "$volume_name:/recover/" -v "$backup_files:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
docker run --rm -v "$volume_name:/recover/" -v "$backup_files:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"
|
echo "ERROR: $backup_files and $backup_sql don't exist"
|
||||||
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user