Exclude/include database objects using regex

Take a backup of all databases ending with prod:

shell> mysqlpump --include-databases=%prod --result-file=db_prod.sql

Suppose there are some test tables in some databases and you want to exclude them from the backup; you can specify using the --exclude-tables option, which will exclude tables with the name test across all databases:

shell> mysqlpump --exclude-tables=test --result-file=backup_excluding_test.sql

The value of each inclusion and exclusion option is a comma-separated list of names of the appropriate object type. Wildcard characters are permitted in object names:

  • % matches any sequence of zero or more characters

  • _ matches any single character

Apart from databases and tables, you ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.