Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There are quite a few discussion on the Interweb on how to backup based on the wildcard table name, but how about wildcard database name?


If I have databases named


I want to only backup db with name prefixed foo, is it possible?

share|improve this question
up vote 3 down vote accepted

You select database names from tables table in information_schema database. you can use filter to filter by your prefix. the use outputed database names to export using mysqldump. a practical example is as follows:

mysqldump -u root -pPASSWORD --databases $(
  mysql -uroot -p -N information_schema \
        FROM tables
        WHERE TABLE_SCHEMA LIKE 'prefix%'"
) > /tmp/backup.sql
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.