From 61aed96c0f9802e8d3f885ddf3be190a26252143 Mon Sep 17 00:00:00 2001 From: "Markus \"Shorty\" Uckelmann" Date: Thu, 7 Sep 2017 16:07:22 +0200 Subject: [PATCH] Fixes missing USE statement in SQL dump This commit adds the additional `--databases` to the mysqldump command. This adds a `USE database` statement to the beginning of the SQl dump. Without this one hast to provide the database name at the restore. --- backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 backup.sh diff --git a/backup.sh b/backup.sh old mode 100644 new mode 100755 index 62bfaa0..20b74fc --- a/backup.sh +++ b/backup.sh @@ -10,7 +10,7 @@ for db in $databases; do then echo "Dumping database: $db" FILENAME=/backup/$DATE.$db.sql - if mysqldump -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" "$db" > "$FILENAME" + if mysqldump -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" -p"$MYSQL_PASS" --databases "$db" > "$FILENAME" then gzip -f "$FILENAME" else