How to Backup Magento 2
If you are running an eCommerce store, you know the importance of the data that you own.
Creating backups is very important for any web application. It is because all the value of a web application is in the data.
The purpose of a backup is to recover the code and data to your store.
If the data is lost, your Magento store is lost. It is important to have a backup plan so that you never lose your store.
If you are using Magento, you can take backups with ease.
How to Take Magento Backup Via SSH
To take a backup of your site, you need to back up both your Magento files and the Magento database.
Here are the steps to back up your Magento files and database via SSH.
- Connect to your server via SSH using the command:
- Navigate to the root directory of Magento. For example:
- Take the Database dump using the command:
mysqldump -h'host' -u'username' -p'password' --opt --single-transaction --quick --routines database > /home/cloudpanel/htdocs/www.domain.com/restore-backup.sql
- Compress the backup file in .tar format.
tar -zcvf backup.tar.gz /home/cloudpanel/htdocs/www.domain.com
How to Take Magento Backup Via FTP
You can backup the Magento store to an external server via FTP.
Severs can get hacked or face downtime. In such a case having a backup on a remote server is better. Backups can get your store online and functional.
You can easily restore the site using a backup from an external source.
Connect to your server using an FTP client. Such as FileZilla or WinSCP.
Navigate to the root directory of Magento. For example:
Download the root directory on your local system and compress it.
Log in to your CloudPanel:
Navigate to Databases > Magento Database
Open the database in PHPMyAdmin.
- Select the database and click on export.
- Choose the Quick exporting method, set SQL as a needed format. Click the Go button and download the database.
It is very important to create backups regularly. Every Magento store owner must have a system to back up the database regularly.
This helps avoid exploits, bugs, hacks, crashes, and any such data loss mistakes.
This tutorial will help execute the Magento 2 store backup. You can follow the steps mentioned above to backup media files, database, and full system.
For more tutorials on Magento, check out the MGT Commerce Tutorials.