MySQL DB Backups Steps

Dump our current database into a *.gz file

With the current command we can deploy our database into a compressed gz file. Replace and with your current database user name and database name.

From terminal:

mysqldump -u <db_user> -p <db_name> | gzip -9 > <db_name>.sql.gz

Once this command is run, we will be asked to enter the user password to the database.

Download the dumped .gz database into our locale storage

Optionally, we may want to download the recently database gz file into our local storage.

Replace , and with proper values.

From terminal:

scp <server_user>@<server_ip>:<server_path_to_gz_file> .

Import our database from a gz database file

With the next command, we will be able to import the database from our gz file to the desire database. Replace and with your current database user name and database name.

From terminal:

zcat <db_name>.sql.gz | mysql -u <db_user> -p <db_name>