mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2024-11-01 08:31:45 +01:00
95c36b6493
This commit adds a gunzip command which extracts the gzip'd SQL dump and pipes it into the mysql command. Without the restore fails.
17 lines
484 B
Bash
Executable file
17 lines
484 B
Bash
Executable file
#!/bin/bash
|
|
[ -z "${MYSQL_USER}" ] && { echo "=> MYSQL_USER cannot be empty" && exit 1; }
|
|
[ -z "${MYSQL_PASS}" ] && { echo "=> MYSQL_PASS cannot be empty" && exit 1; }
|
|
|
|
if [ "$#" -ne 1 ]
|
|
then
|
|
echo "You must pass the path of the backup file to restore"
|
|
fi
|
|
|
|
echo "=> Restore database from $1"
|
|
set -o pipefail
|
|
if gunzip --stdout "$1" | mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS"
|
|
then
|
|
echo "=> Restore succeeded"
|
|
else
|
|
echo "=> Restore failed"
|
|
fi
|