Steve Gricci
Geek. Coder. Father.

October 5th, 2011

mysqldump and gzip one-liner

I frequently download mysql backups from our production environment (at off hours of course) to do testing with actual data. As a force of habit, I've always just mysqldump'ed the data and then gzip'ed as two separate commands.

Here's a one liner that I've started using instead.

mysqldump <mysql_options> | gzip -9 > file.sql.gz

Note: the -9 in the gzip command is the compression level, 9 being the maximum compression

 

I like to create stuff here.

You can find me at these places:

GitHub
Twitter
Flickr
Gimme Bar
Last.fm

Subscribe