Have a Question?
How do I make a backup of the database?
Table of contents
Almost every modern website uses a MySQL database. More popular content management systems, such as WordPress, Magento, Joomla, store all data in a MySQL database. If, for some reason, we want to back up the database, such as a MySQL server update, then it is possible to extract the data stored in the database or to recover the dump in case of a possible error.
Compress a folder
After you connect to the server via SSH, you can create a backup by issuing the following command:
mysqldump -u user_name -p database_name --single-transaction | gzip -2 > db.sql.gz
By issuing the above command, you create a compressed dump with a single transaction token.
mysqldump -u user_name -p database_name > db.sql
Extract an archive
You can do this by issuing the following command
gunzip < db.sql.gz | mysql -u user_name -p database_name
mysql -u user_name -p database_name < db.sql