Backup mysql in linux can be done by using mysqldump. The output of dumping is .sql file. We can combine mysqldump with gzip command to compressing the result.
Command for backup:
mysqldump -u username -p db_name | gzip -9 > db_name.sql.gz
Command for restore
zcat db_name.sql.gz | mysql -u username -p db_name
Another command can be use for backup and transfer the result using ssh to another server.
mysqldump --opt <database> | gzip -c | ssh user@otherserver 'cat > /tmp/yourdbname.sql.gz'
Source:
https://coderwall.com/p/ylpnvq/mysqldump-gzip-best-combo
https://serverfault.com/questions/106595/mysqldump-to-a-tar-gz