mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-21 16:01:03 +01:00
Changed logic so that volume is not created for db recoveries
This commit is contained in:
parent
ace1a70488
commit
15a1f17184
@ -8,7 +8,7 @@ fi
|
|||||||
|
|
||||||
volume_name="$1" # Volume-Name
|
volume_name="$1" # Volume-Name
|
||||||
backup_hash="$2" # Hashed Machine ID
|
backup_hash="$2" # Hashed Machine ID
|
||||||
version="$3" # version to backup
|
version="$3" # version to recover
|
||||||
|
|
||||||
# DATABASE PARAMETERS
|
# DATABASE PARAMETERS
|
||||||
database_type="$4" # Valid values; mariadb, postgress
|
database_type="$4" # Valid values; mariadb, postgress
|
||||||
@ -26,17 +26,6 @@ echo "Inspect volume $volume_name"
|
|||||||
docker volume inspect "$volume_name"
|
docker volume inspect "$volume_name"
|
||||||
exit_status_volume_inspect=$?
|
exit_status_volume_inspect=$?
|
||||||
|
|
||||||
if [ $exit_status_volume_inspect -eq 0 ]; then
|
|
||||||
echo "Volume $volume_name already exists"
|
|
||||||
else
|
|
||||||
echo "Create volume $volume_name"
|
|
||||||
docker volume create "$volume_name"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "ERROR: Failed to create volume $volume_name"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$backup_sql" ]; then
|
if [ -f "$backup_sql" ]; then
|
||||||
if [ -n "$database_container" ] && [ -n "$database_password" ] && [ -n "$database_name" ]; then
|
if [ -n "$database_container" ] && [ -n "$database_password" ] && [ -n "$database_name" ]; then
|
||||||
echo "recover mysql dump"
|
echo "recover mysql dump"
|
||||||
@ -51,6 +40,17 @@ if [ -f "$backup_sql" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $exit_status_volume_inspect -eq 0 ]; then
|
||||||
|
echo "Volume $volume_name already exists"
|
||||||
|
else
|
||||||
|
echo "Create volume $volume_name"
|
||||||
|
docker volume create "$volume_name"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR: Failed to create volume $volume_name"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -d "$backup_files" ]; then
|
if [ -d "$backup_files" ]; then
|
||||||
echo "recover files"
|
echo "recover files"
|
||||||
docker run --rm -v "$volume_name:/recover/" -v "$backup_files:/backup/" "kevinveenbirkenbach/alpine-rsync" sh -c "rsync -avv --delete /backup/ /recover/"
|
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