Magento Server Backup: How to Backup Magento Server Data

Magento Server Backup: How to Backup Magento Server Data. In this post, we introduce Magento, the importance of Magento backup then show you different ways to backup Magento server data.

Magento is a flexible eCommerce platform that allows businesses to create responsive online storefronts as well as maintain them. Businesses of all sizes improve their online sales performance using its robust features. No matter whether you are planning on starting your first online store or wanting to grow an already established business, this open source eCommerce platform assists you in achieving your goals.

What is Magento

You may choose from Magento Open Source and Magento Commerce – the two separate versions of this eCommerce solution.

Magento Open Source

It is a free, self hosted eCommerce platform that offers access to basic and essential features required by small businesses and shop owners. They even create their own solutions or enlist the help of a developer if they know how to code. It includes access to site search, mobile commerce, SEO, product browsing, instant purchase, integrated check-up, and more built in functionalities.

Magento Commerce

The paid, enterprise level version is also referred to as Adobe Commerce. It is built using the same basic framework as Magento Open Source but with a few additional features and functionalities. It is a comprehensive PaaS cloud solution that offers support for customizations and third party integrations.

All B2B and B2C eCommerce businesses willing to sell across different locations use this version to fulfil their requirements. Live chat, visual merchandising, WYSIWYG Page builder, BI Dashboard, and bespoke catalogues are a few additional features supported by Magento Commerce.

What is Magento 2?

Magento 2 is an upgraded version with some outstanding features along with the ones present in the old version. It supports the latest PHP versions, HTML5, MySQL, fast page load speed, mobile responsiveness, and more. Although, you might face a few security risks or restrictions to payment methods with Magento 2.

With Magento 2, it is best to get a backup on a regular basis to protect your data from mishaps or unwanted events. Be it update failure, software issues, or other security risks, you must be ready for anything.

When do We need Magento Server backup?

Backing up Magento Server helps maintain the security and availability of your website data and files. With regular backups, you reduce security risks and restore your crucial files quickly during emergencies. Below are a few situations that call for backing up the Magento server:

  • Prior to Performing Updates – If you want to install extensions or update your Magento installation, it is best to create a backup for emergencies. Also, if you are going to perform any major website changes, having a backup is crucial. As a result, if any problems develop during the upgrade process, you use this to go back to a previous working state.
  • Moving or Migrating Website – Having a backup of your current server is crucial when migrating your Magento website to a new server. This makes sure that, in the event of data loss or other problems during the migration process, you quickly recover the data on your website.
  • Before making configuration changes – It is advisable to save a backup if you want to change the server specifications, including PHP settings, caching techniques, or server parameters. The adjustments are then be undone if any unanticipated issues arise.
  • Content Modification or Data Updates – It is a good practice to back up your Magento server after making changes to content or data, i.e., customer information, product data, or other crucial data. With regular backups, all recent modifications are safe and can be undone whenever any unanticipated issues occur.

Magento Server Backup: How to Backup Your Magento Server Data

In this section, we show you different ways to back up your Magento server data.

Prerequisites

  • A root password or a user with sudo privileges

Types of Magento Backup

There are three different types of backups that you create either via cli or via the admin panel.

System Backup: This backup includes everything like file system, media, and database.

Database and Media Backup: Using this option, you create a backup of the media folder and database.

Database Backup: This option only creates a backup of the Magento database.

Set the Open Files Limit

Before creating a Magento backup, you need to change the open files limit value for the Magento system user. Default open files limit value leads to a faulty backup. So it is recommended to set the open files limit value to 65536 or more as per your requirements.

To set the open files limit value to 65536, run the following command as a Magento system user.

				
					ulimit -s 65536
				
			

Enable the Magento 2 Backup Tool

Magento offers an in built backup tool that allows you to backup Magento via cli as well as the admin panel. However, it is disabled by default. To enable the Magento backup tool, log in to the Magento server as a Magento system user and run the following command.

				
					bin/magento config:set system/backup/functionality_enabled 1
				
			

This enables Magento backup tool. Now proceed to create Magento backup.

Backup Magento Server Data via CLI

The basic syntax to create a Magento backup is shown below:

				
					php bin/magento setup:backup [--code] [--media] [--db]
				
			

For example, to back up the Magento filesystem and database, run the following command in your terminal interface.

				
					php bin/magento setup:backup --code --db
				
			

After the successful backup, you see the following screen.

Now list your created backup using the following command.

				
					php bin/magento info:backups:list
				
			

This lists both backup files in the following screen.

By default, Magento backup stores their backup inside the var/backup directory. Verify both using the following command.

				
					ls var/backups/ -l
				
			

This shows you both backup files in the following output.

				
					total 134340
-rw-rw-r-- 1 root root 607018 Jul 9 13:20 1688908726_db.sql
-rw-rw-r-- 1 root root 136952746 Jul 9 13:20 1688908726_filesystem_code.tgz
				
			

Restore Magento Backup via CLI

Moreover, Magento also offers roll back features that allow you to restore your backup easily in the event of failure. To roll back the Magento backup, you need a valid backup file name. To see all existing backups, run the following command.

				
					php bin/magento info:backups:list
				
			

Output.

				
					Showing backup files in /var/www/html/magento/var/backups.
+-----------------------------------+-------------+
| Backup Filename | Backup Type |
+-----------------------------------+-------------+
| 1688908726_filesystem_code.tgz | code |
| 1688908726_db.sql | db |
| 1688910118_media_systembackup.tgz | media |
+-----------------------------------+-------------+

				
			

To roll back the filesystem backup, run the following command using the option -d followed by the backup name.

				
					php bin/magento setup:rollback -c 1688908726_filesystem_code.tgz
				
			

You see the following screen.

If you want to roll back the database backup, use the -d option as shown below.

				
					php bin/magento setup:rollback -d 1688908726_db.sql
				
			

To roll back the media backup, use the -m option as shown below.

				
					php bin/magento setup:rollback -m media-backup
				
			

Backup Magento Server Data via Admin Panel

Also backup your Magento server data via Magento admin panel. Follow the below steps to backup Magento server data via the admin panel.

First, log in to your Magento admin panel and click on System > Tools > Backups. You should see the following screen.

Now, click on any of the following options.

  • System Backup.
  • Database and Media Backup.
  • Database Backup.

You should see the following screen.

Provide your backup name, tick the Maintenance mode checkbox then click Ok to initiate the backup. Once the backup process is completed successfully, you see the following screen.

Provide your backup name, tick the Maintenance mode checkbox then click Ok to initiate the backup. Once the backup process is completed successfully, you see the following screen.

Restore Magento Backup via Admin Panel

The Magento restoration process erases all the data generated by your eCommerce store after the backup was created. To restore the Magento backup, log in to the Magento admin panel and click on System > Tools > Backups. You see all your backup on the following screen.

Now, click on the Rollback of your preferred backup then provide the following information.

User Password: Provide your Magento admin password.

Maintenance mode: Click the checkbox to enable maintenance mode during the rollback.

Once you are done, click on the Ok to proceed with the restore process.

Magento Server Backup: How to Backup Magento Server Data Conclusion

In this blog post, we showed you how to create a Magento backup and roll back it via the CLI tool. We also explained to back up and roll back Magento data via admin panel. Now choose your preferred way to backup and restore your backupdata.

Server failure, data corruption, and security breaches are a few common challenges that one must be prepared for. Hence, it is best to create backups and keep them in a separate area from your live server. Additionally, it is important that you run regular backup tests to make sure they are operating properly. Also, it shall be effectively restored when necessary.

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x