mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-22 08:21:04 +01:00
Optimized mysql recovery
This commit is contained in:
parent
eddccb1936
commit
9fa37046ab
@ -19,14 +19,18 @@ if [ $exit_status_volume_inspect -eq 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$backup_sql" ]; then
|
if [ -f "$backup_sql" ]; then
|
||||||
echo "recover mysql dump"
|
if [ -n "$container" ] && [ -n "$mysql_root_password" ] && [ -n "$database" ]; then
|
||||||
cat $backup_sql | docker exec -i "$container" /usr/bin/mysql -u root --password="$mysql_root_password" $database
|
echo "recover mysql dump"
|
||||||
exit 0
|
cat $backup_sql | docker exec -i "$container" /usr/bin/mysql -u root --password="$mysql_root_password" $database
|
||||||
else
|
exit 0
|
||||||
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
|
||||||
|
echo "a database backup exists, but a parameter is missing. Files will be recovered instead."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
echo "ERROR: $backup_files and $backup_sql don't exist"
|
echo "ERROR: $backup_files and $backup_sql don't exist"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user