The way to Backup Your Magento 2 Retailer

Getting your Magento 2 retailer backed up commonly is likely one of the most necessary points of guaranteeing that it stays shielded from the implications of undesirable occasions.

Failed updates, server {hardware} or software program points, varied safety threats — you might want to be ready for all the pieces, understanding all of your knowledge will be simply recovered.

Under we’re going to learn to backup Magento 2 shops utilizing three totally different strategies. To study extra about Magento 2 backups, simply hold studying.

The forms of backups

Magento is an ecommerce platform that can present limitless alternatives to retailer house owners, which makes having a backup technique much more important.

Magento 2 turned a successor to the Magento 1 content material administration system when the latter reached its finish of life, and primarily prolonged the performance of the earlier model.

All merchandise added, prospects’ orders, session knowledge like carts, and a considerable amount of different data — all of that is saved inside the Magento 2 database, and we cannot enable any of that to be misplaced. That’s the place a backup is available in.

Get absolutely managed Magento internet hosting

Speed up your retailer’s potential, with out the continued upkeep

There are three forms of Magento 2 backups we are able to create:

  • System backup. Any such backup saves all the pieces, together with the Magento 2 file system, the media folder, and the database.
  • Database and media backup. Because the title suggests, you possibly can create a backup of your media folder and the Magento 2 database.
  • Database backup. If you need to avoid wasting a backup of your database solely, that can also be potential.

We are able to backup Magento 2 web sites from the admin panel, command line, making use of the Magento instructions, or by making a Magento 2 backup manually.

The method of making a backup manually will be utilized to another content material administration system.

By way of the command line

Magento 2 backups will be created from the command line utilizing sure Magento instructions.

Backups created are saved within the var/backups folder inside your retailer set up listing and can be utilized to revive the web site at any time.

Let’s see how one can backup Magento 2 from the command line.

Step 1: Log in to the server through SSH and go to your Magento 2 retailer set up listing

To create a backup, we should be logged in through SSH with the account person. As soon as we’re logged in, let’s transfer to the doc root of our retailer the place our Magento 2 set up resides.

As you possibly can see within the screenshot beneath, now we have logged in because the magentotest person, which is the proprietor of our Magento set up, and public_html is our present working listing.

The person we're logged in as

[magentotest@newvps public_html]$ whoami
magentotest

Our present working listing

[magentotest@newvps public_html]$ pwd
/home2/magentotest/public_html

Step 2: Create a backup

Utilizing the magento setup:backup command, we are able to backup our Magento 2 retailer quick and simply. With the assistance of the flags we are able to apply to the instructions, we are able to specify what kind of a backup we want to create.

Please notice that the backup command will put the shop into upkeep mode. When your retailer is put into upkeep mode, its entrance web page will show a message saying that the web site is at the moment unavailable.

As soon as a backup is full, the shop might be operational once more.

Associated studying: The way to create a customized Magento 2 upkeep web page with out utilizing an extension >>

Within the instance beneath, now we have created a full system backup containing our Magento 2 file system, the media listing, and the database; you possibly can see the corresponding flags –code, –media, –db we used.

magentotest@newvps public_html]$ magento setup:backup --code --media --db
Enabling upkeep mode
Code backup is beginning...
Code backup filename: 1648215256_filesystem_code.tgz (The archive will be uncompressed with 7-Zip on Home windows programs)
Code backup path: /home2/magentotest/public_html/var/backups/1648215256_filesystem_code.tgz
[SUCCESS]: Code backup accomplished efficiently.
Media backup is beginning...
Media backup filename: 1648215256_filesystem_media.tgz (The archive will be uncompressed with 7-Zip on Home windows programs)
Media backup path: /home2/magentotest/public_html/var/backups/1648215256_filesystem_media.tgz
[SUCCESS]: Media backup accomplished efficiently.
DB backup is beginning...
DB backup filename: 1648215256_db.sql
DB backup path: /home2/magentotest/public_html/var/backups/1648215256_db.sql
[SUCCESS]: DB backup accomplished efficiently.
Disabling upkeep mode

Step 3: View the backups you created

We are able to discover all of the backups we created each from the command line and the admin panel within the var/backups listing.

Let’s check out the checklist beneath.

We now have 2 backups that we created from the admin panel, and the complete backup we simply created, which consists of three recordsdata: the database backup, Magento 2 file system, and the media recordsdata archives.

The backups created from the admin panel

-rw-rw-r-- 1 magentotest magentotest 136702556 Mar 24 16:14 1648209993_snapshot_March_25.tgz
-rw-rw-r-- 1 magentotest magentotest    943961 Mar 24 16:16 1648210578_db_March_25.sql

The complete backup we created from the command line

-rw-rw-r-- 1 magentotest magentotest   1113288 Mar 25 12:38 1648215256_db.sql
-rw-rw-r-- 1 magentotest magentotest 133462787 Mar 25 12:38 1648215256_filesystem_code.tgz
-rw-rw-r-- 1 magentotest magentotest    110237 Mar 25 12:38 1648215256_filesystem_media.tgz

The backup listing

[magentotest@newvps backups]$ pwd
/home2/magentotest/public_html/var/backups

Restoring from a backup through command line

You may restore your web site from any of the backups saved out of your admin panel or utilizing the magento setup:rollback command.

For instance, beneath now we have restored our Magento retailer from the complete system backup we created earlier from the command line, however skipped the restoration of the database.

The flags that can be utilized are -m, -c, and -d for media, file system, and database restoration accordingly. All flags should be adopted by the backup file we’re restoring from.

[magentotest@newvps backups]$ magento setup:rollback -c 1648215256_filesystem_code.tgz -m 1648215256_filesystem_media.tgz
Enabling upkeep mode
You're about to take away present code and/or database tables. Are you positive?[y/N]y
Do you wish to hold the backups?[y/N]y
Code rollback is beginning ...
Code rollback filename: 1648215256_filesystem_code.tgz
Code rollback file path: /home2/magentotest/public_html/var/backups/1648215256_filesystem_code.tgz
[SUCCESS]: Code rollback accomplished efficiently.
Media rollback is beginning ...
Media rollback filename: 1648215256_filesystem_media.tgz
Media rollback file path: /home2/magentotest/public_html/var/backups/1648215256_filesystem_media.tgz
[SUCCESS]: Media rollback accomplished efficiently.
Disabling upkeep mode

By way of the admin panel

We are able to simply create a Magento 2 backup from the admin panel.

This technique doesn’t require connecting to the server immediately through SSH as we did after we created a backup utilizing the Magento command line interface.

Under we’re going to learn to backup Magento 2 from the admin panel.

Step 1: Log in to your Magento 2 admin panel

Log in to the Magento admin panel utilizing your admin person credentials.

Step 2: Select system > backups from the left menu

You will discover backups underneath the instruments part of the system menu.

Step 3: Select the backup kind and run a backup

When you open the backup menu it is possible for you to to see the backups you might have saved to the disk, or run a brand new backup.

For instance, let’s run a system backup. We might be requested to call the brand new backup, and select whether or not we want to put the shop into upkeep mode.

We strongly suggest doing so for a backup to run with none points, and ensure no new knowledge will get added or modified whereas a brand new backup is being saved.

There’s additionally an choice to exclude the media folder from being backed up.

As soon as you might be prepared, click on Okay, and a backup will begin operating.

Step 4: Confirm the backup accomplished efficiently

As soon as a brand new backup is created, it will likely be added to the checklist of obtainable backups.

You may obtain a backup to your pc or restore your Magento 2 retailer from the identical interface.

Configuring common backups from the admin panel

A brand new backup of your Magento 2 retailer will be created from the admin panel anytime, however the course of will be automated. We are able to configure backups to be operating at a sure time day by day, weekly, or month-to-month.

Should you nonetheless should not have backups saved commonly, let’s see how we are able to allow this selection from the admin panel.

Step 1: Select shops from the left menu and click on on configuration

Configuration will be discovered underneath settings within the shops menu.

Step 2: Select the superior tab and click on on system underneath it

There we can see among the superior system settings, together with the backup schedule.

Step 3: Configure the backup frequency

We are able to allow scheduled backups from the backup settings menu, together with the backup kind, frequency, and the time you prefer to backups to run at.

Handbook backup

The method of making a guide backup of a Magento 2 retailer is similar as saving certainly one of any web site utilizing a unique content material administration system. We have to backup the web site database and all its recordsdata.

Let’s evaluate the method of making a backup manually that may assist us perceive how one can backup Magento 2 web sites if we for some purpose cannot do it utilizing the 2 strategies we coated beforehand.

Step 1: Create a backup of the database

Making a database backup will be achieved in several methods. We are able to do it utilizing a well-liked database administration instrument like phpMyAdmin.

As soon as we open phpMyadmin we are able to select our Magento 2 database from the checklist on the left and select the Export choice from the highest menu. Fast export technique can be utilized, except you want to customise the database backup.

Click on on Go as soon as prepared, and an SQL file containing your database backup might be downloaded to your pc.

Step 2: Backup the shop recordsdata

You may obtain a backup of your Magento 2 retailer recordsdata from the file supervisor interface or by connecting to the recordsdata through SFTP.

As you see beneath, now we have linked to our retailer recordsdata through SFTP utilizing FileZilla, and downloaded the entire listing containing our Magento 2 retailer recordsdata.

You may create an archive from the database backup and the recordsdata you downloaded, and retailer it in your pc.

If you might want to restore your web site from a backup you manually created, you possibly can simply add it to the server and overwrite the present recordsdata and the database your self, or contact your internet hosting supplier’s technical assist for help.

Now you already know

Backing up your Magento 2 retailer is of main significance to make sure all knowledge is secure and will be simply recovered.

Now that now we have realized how one can backup Magento 2, we are able to see that the method doesn’t require a lot time or effort. We are able to create backups utilizing no less than three totally different strategies: through the Magento command line interface, admin panel, or by saving a backup manually.

Computerized backups can be configured to run commonly which is one other nice choice.

Take into account managed Magento internet hosting with Nexcess

Caring for all technical points of your on-line enterprise will be exhausting, and also you as a enterprise proprietor cannot enable your web site to be managed by anybody however a workforce of consultants.

Managed internet hosting will help you delegate most duties to the system administration professionals, retaining your retailer secure and safe.

Nexcess managed Magento internet hosting plans come prepackaged with all the very best options and are optimized for safety, efficiency, and scalability.

Try our managed Magento plans to get began right now.

SHARE THIS POST