Database Backup (only particular tables) – MYSQL

How do you take a database backup for only particular tables, that too dynamically… Say i have tables like map1, map2, map3, ….. map1000. How do you write a query? Don’t worry it’s very simple :) Just follow the below command

mysql test_v382_development -u root -proot -e ‘show tables like “map%”‘ | grep -v Tables_in| xargs mysqldump  test_v382_development -u root -proot emp dept > backup.sql

The above command will take the database backup for the tables, map1, map2, … mapN dynamically and the tables ’emp’ and ‘dept’. Other tables in the database will not be included in the database backup.

Advertisements