Parallel mysql dump restore

find -print0 | xargs -0 -n 1 -P 4 -I {} sh -c "zcat '{}' | mysql nix"
this command works with one gziped file per table, and restore 4 tables in parallel.
Sample Output
see mytop output

By: skygreg
2009-08-25 15:05:55

What Others Think

You can avoid the use of echo with xargs' -I (capital i) option: ls -1 | xargs -n 1 -P 4 -I {} sh -c "zcat '{}' | mysql nix" the '{}' is quoted in case the filenames have spaces. If you have really funky filenames, use "find . -print0 | xargs -0 ..."
bwoodacre · 664 weeks and 6 days ago
ok thank you it is effectively better, I have edited the original command.
skygreg · 664 weeks and 6 days ago
Through this website, you can learn so many such Linux commands and using such commands makes your tasks plastic card printer easier. The above command works with one gziped file per table, and restores 4 tables in parallel. I am expecting more such commands from here and will keep sharing more updates on that.
Alyssalauren · 25 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: