Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 2 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.