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.
This commit is contained in:
Markus "Shorty" Uckelmann 2017-09-07 16:07:22 +02:00
parent b3bb91adf7
commit 61aed96c0f

2
backup.sh Normal file → Executable file
View file

@ -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