docker-mysql-cron-backup/restore.sh
Fco. Javier Delgado del Hoyo 44cdee455a update docker and bash syntax
2017-04-16 11:29:31 +02:00

16 lines
452 B
Bash

#!/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"
if mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" < "$1"
then
echo "=> Restore succeeded"
else
echo "=> Restore failed"
fi