Take a mysqldump, tar gz it – all in a handy one liner

bash

I wanted to take a mysqldump of one database, then compress it into a .tar.gz file and all as quickly as possible and with one command.

It’s considerably quicker to import a mysql database from a .gz file, and so this line was very useful for me:

mysqldump my_db -u root | gzip -c | cat > my_db-$(date +%Y-%m-%.%M.%S).sql.gz

Leave a Reply

Your email address will not be published. Required fields are marked *