nyson
nyson

Reputation: 1055

mysqldump database with whitespace in database name

I'm constructing a backup script for usage on some servers. The problem is that I have a database that contains whitespace, " aa_something_something". This is probably a mistake in the setup, but I don't have enough information to make a qualified decision of removing it yet, so I'm just going to include it into the backup.

This is my current mysqldump call:

mysqldump -B $db -u$DB_USER -p$DB_PASS --skip-lock-tables 2>> $ERROR_LOG_FILE

As the space is in the beginning, mysqldump thinks I want to backup "aa_something_something" instead of " aa_something_something". Is there anyway to escape spaces inside variables? I tried ' and ", but it didn't work.

Upvotes: 0

Views: 2323

Answers (1)

Mat
Mat

Reputation: 206679

Just quote it:

mysqldump -B "$db" ...

But the only long-term sane thing to do is to remove that space and fix the places that used that weird name.

Also please, please do make sure you can restore from that backup before doing anything radical. That whitespace could mess up any number of things.

Upvotes: 1

Related Questions