From 41ea03511f5acc62ad0253f463ded9c10b6b86f3 Mon Sep 17 00:00:00 2001 From: Stelage Date: Sun, 9 May 2021 17:58:46 +0200 Subject: [PATCH] Quotes on SQL var was missing. --- restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restore.sh b/restore.sh index ab365f2..3ca9e92 100755 --- a/restore.sh +++ b/restore.sh @@ -13,13 +13,13 @@ SQL=$(gunzip -c "$1") DB_NAME=${MYSQL_DATABASE:-${MYSQL_DB}} if [ -z "${DB_NAME}"] then - DB_NAME=$(echo $SQL | grep -oE '(Database: (\w*))' | cut -d ' ' -f 2) + DB_NAME=$(echo "$SQL" | grep -oE '(Database: (\w*))' | cut -d ' ' -f 2) fi [ -z "${DB_NAME}" ] && { echo "=> database name cannot be found" && exit 1; } echo "=> Restore database $DB_NAME from $1" -if echo $SQL | mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" "$DB_NAME" +if echo "$SQL" | mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" "$DB_NAME" then echo "=> Restore succeeded" else