In order to use compression over the wire for a faster transfer, pass the --compress
option to mysqldump
. Example:
mysqldump -h db.example.com -u username -p --compress dbname > dbname.sql
Important: If you don't want to lock up the source db, you should also include --lock-tables=false
. But you may not get an internally consistent db image that way.
To also save the file compressed, you can pipe to gzip
.
mysqldump -h db.example.com -u username -p --compress dbname | gzip --stdout > dbname.sql.gz