Compressing mysqldump output with gzip

Tags: April 29, 2012 2:52 PM

Compressing mysqldump ouput is a good practice since your sql dump file could be very big. The good thing is the result of the dump is in plain text, so tools such gzip can siginificanly reduce the size.

# mysqldump -u username -ppassword databasename | gzip > dbname.sql.`date +%Y-%m-%d_%H%M%S`.gz
Put it to cron for daily backup. Cron treat '%' as special character so it needs to be escaped.
0 0 * * * mysqldump -u username -ppassword databasename | gzip > dbname.sql.`date +\%Y-\%m-\%d_\%H\%M\%S`.gz

Share on Facebook Twitter

0 comments:

Post a Comment