Learn how to Backup Your Magento 2 Retailer

Getting your Magento 2 retailer backed up commonly is without doubt one of the most vital features of making certain that it stays shielded from the results of undesirable occasions.

Failed updates, server {hardware} or software program points, numerous safety threats — it is advisable to be ready for every little thing, understanding all of your information will be simply recovered.

Beneath we’re going to discover ways to backup Magento 2 shops utilizing three totally different strategies. To study extra about Magento 2 backups, simply maintain studying.

The varieties of backups

Magento is an ecommerce platform that can present limitless alternatives to retailer homeowners, 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 basically prolonged the performance of the earlier model.

All merchandise added, prospects’ orders, session information 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 totally managed Magento internet hosting

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

There are three varieties of Magento 2 backups we will create:

  • System backup. This sort of backup saves every little thing, together with the Magento 2 file system, the media folder, and the database.
  • Database and media backup. Because the identify suggests, you possibly can create a backup of your media folder and the Magento 2 database.
  • Database backup. If you want to save lots of a backup of your database solely, that can also be attainable.

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 the right way to 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 must 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 under, we now 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 will backup our Magento 2 retailer quick and simply. With the assistance of the flags we will apply to the instructions, we will specify what sort of a backup we wish to create.

Please observe 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 will likely be operational once more.

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

Within the instance under, we now 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 techniques)
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 techniques)
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 under.

We’ve got 2 backups that we created from the admin panel, and the complete backup we simply created, which consists of three information: the database backup, Magento 2 file system, and the media information 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 total 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’ll be able to restore your web site from any of the backups saved out of your admin panel or utilizing the magento setup:rollback command.

For instance, under we now 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 must 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 maintain 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 methodology doesn’t require connecting to the server instantly through SSH as we did once we created a backup utilizing the Magento command line interface.

Beneath we’re going to discover ways 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’ll find backups underneath the instruments part of the system menu.

Step 3: Select the backup sort and run a backup

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

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

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

There may be 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 is going to be added to the checklist of obtainable backups.

You’ll be able to obtain a backup to your laptop 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 each day, weekly, or month-to-month.

In the event you nonetheless wouldn’t have backups saved commonly, let’s see how we will 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 a number of 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 sort, frequency, and the time you want to backups to run at.

Guide backup

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

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

Step 1: Create a backup of the database

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

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

Click on on Go as soon as prepared, and an SQL file containing your database backup will likely be downloaded to your laptop.

Step 2: Backup the shop information

You’ll be able to obtain a backup of your Magento 2 retailer information from the file supervisor interface or by connecting to the information through SFTP.

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

You’ll be able to create an archive from the database backup and the information you downloaded, and retailer it in your laptop.

If it is advisable to restore your web site from a backup you manually created, you possibly can simply add it to the server and overwrite the prevailing information and the database your self, or contact your internet hosting supplier’s technical help for help.

Now

Backing up your Magento 2 retailer is of major significance to make sure all information is protected and will be simply recovered.

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

Automated backups will also be configured to run commonly which is one other nice choice.

Contemplate managed Magento internet hosting with Nexcess

Taking good care of all technical features 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 staff of specialists.

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

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

Take a look at our managed Magento plans to get began in the present day.

SHARE THIS POST