Are you afraid of being attacked or losing your data? Then, creating a backup is a brilliant way to save the online business harmless.
Luckily, Magento 2 allows users to create a database backup through the admin interface.
However, problems like insufficient disk space, backup disabled, wrong file permission can create errors while creating a database backup.
At Bobcares, we often get requests from our customers to create Magento 2 database backup as part of our Server Management Services.
Today, let’s get into the details on how our Support Engineers create database backup in Magento 2 and fix related errors.
How we Backup the Database in Magento 2
Creating backups for Magento 2 is a basic requirement. Because it is a data recovery method that can protect all data from the disappearance due to any change or break on the site. Also, It is also possible to use the Magento Backups management to back up filesystems, databases, media files and so on.
Moreover, database backup files are compressed using the .gz format.
Here, let’s see how Support Engineers create a perfect database backup for Magento 2 sites.
1. Initially, we login to the Magento admin panel.
2. Then, go to System >> Tools >> Backup.
3. We click the option Database Backup. It will generate a message for the confirmation to proceed with the backup generation. So, click on the OK button to proceed with the backup generation.
4. Also, we enter the backup name and click OK button.
5. Finally, a new database can be seen in the section System >> Tools >> Backup.
Magento 2 database backup – Related errors and fixes
At Bobcares, where we have more than a decade of expertise in managing servers, we see that many of our clients face problems with Magento servers.
Now, let’s see how our Support Engineers fixed common errors.
1. Insufficient value for max_execution_time
Recently, one of our customers had a problem with his system upgrade. While running system upgrades, the backup process got failed and showed the below error messages.
On checking, our Support Engineers found that the max_execution_time is 30 seconds, which was very small to execute a PHP script. As a result, it caused PHP script timeout errors.
So, we increased max_execution_time to higher value and solved the error.
2. Wrong file permission
Sometimes, many customers may face errors when trying to run a database backup. It will show an internal server error.
In certain cases, the backup can change all file/folder permissions. Then, we have to run a script to change folder permissions to 755 and file permissions to 644.
Often, this is happening with the index.php in the Magento root folder. The permissions set up as 600 instead of 644. So, we roll back the permission of index.php file.
This fixed the error.
In addition, another reason for backup failure may be due to the insufficient permission of the Magento file system owner or wrong ownership of the Magento file system.
Especially, the file system permissions and ownership of the <magento_root>/var directory and subdirectories.
3. Backup disabled
Similarly, sometimes the backup functionality does not work as we expect or displays the following message,
Backup functionality is disabled.
Backup functionality is currently disabled. Please use other means for backups.
Then, we need to enable the feature prior to backing up. For that, our Support Engineers run the following command.
bin/magento config:set system/backup/functionality_enabled 1
4. Insufficient disk space for Magento 2 database backup
The backup failure can occur due to insufficient disk space on the server. Normally, free up disk space by transferring some files to another storage device or drive can solve the problem.
[Need assistance to fix Magento errors? We’ll help you.]
In short, problems like insufficient disk space, backup disabled, wrong file permission can create errors while creating a Magento 2 database backup. Today, we saw how our Support Engineers assisted our customers to create a database backup from the Magento administration panel and fixed the errors.