The fine fine art of command line programming keeps suprising me, it’s brilliant what you can acomplish with a few lines of commands all mixed up in grep and other linux commands.I’m working on a huge wordpress mu project and have run into problems with upgrading from version 1.1.1 to the latest version (currently 2.7), so now I decided to move some of the data to my laptop and try to recreate the problems. But I do not want to move all ~20 GB data since I only need a few blogs for testing.
I googled the task and found a mix of options, after a few minutes of testing I came up with this lovely little commandline:
mysql databasename -u [root] -p[password] -e 'show tables like "wp_153_%"' | grep -v Tables_in | xargs mysqldump [databasename] -u [root] -p[password] > [target_file]
Beauty full isn’t it :)
It will grap all tables containing “wp_153_*” and dump this into your target file.