commandline mysql backup restore with compression sql.gz
![Image](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDuNGaGWObw-VAhG0MTrlZHAIruf19rrgoVzplp9VKd_ty8d_PN8cYpcpK6L9aiFZ8-Xri1jZgNLeR-wPAywDX3g-PgCuJf86H6ko9ExlyUeaDk17raB2CniL-DMMVFmFOj9jYuNtiOA/s320/MySQL-Backup.jpg)
When you do mysql database backup from commandline it is good for a bigger database to use compression . It prevents backup to have bigger size and will reduce bandwidth usage also in case of remote backup. A strandard command for backing up mysql database is as bellow # mysqldump -u <user> -p<password> <databasename> > dbbackupfile.sql Example : in case db name is mydb1, user is dbuser1, password password123. # mysqldump -u dbuser1 -ppassword123 mydb1 > mydb1bkp.sql In above now you can apply comperssion to reduce size of output backup file. # mysqldump -u dbuser1 -ppassword123 mydb1 | gzip -9 > mydb1bkp.sql.gz Now while restoring this use bellow # gunzip -p mydb1bkp.sql.gz | mysql -u dbuser1 -ppassword123 mydb1 Using above command -p switch with gunzip pipes the output to mysql command for given database.