Rate this post

Part 6: Backup and rollback

Welcome to our serial articles on Magento 2 Command Lines (CLI)!

You know Magento 2 has provided the powerful command-line interface tool (CLI). It allows you to perform tasks including installation, configuration, database backups, compiling LESS etc. Today I will show you how to backup and rollback your Magento store (includes file system, media and database). Before starting this guide, please review our previous posts.

Backup and Rollback

1. Backup Magento

The command below will help you create backup of your Magento store

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

This command will process these tasks below:

  • Put Magento store in maintenance mode
  • Create backup file then store it at [Magento_Folder]/var/backups
  • Take Magento store out of maintenance mode

The command below will backup only Magento database

php bin/magento setup:backup –db

2. Rollback Magento

  • You can rollback Magento from the backup that you created in the past. To see the list of backup, use the command below
php bin/magento info:backups:list
  • Then rollback one of previous backups
php bin/magento setup:rollback [-c|–code-file=”<name>”] [-m|–media-file=”<name>”] [-d|–db-file=”<name>”]
  • The command below will rollback a db backup named 1434133011_db.gz
php bin/magento setup:rollback -d 1434133011_db.gz
  • After performed this command, you got the message in console
[SUCCESS]: Database rollback completed successfully.

Please set file permission of bin/magento to executable

Disabling maintenance mode

Your Magento website needs a powerful Magento ERP for stock control.

DON'T MISS THE CHANCE!

magento erp

How to Install Magento 2 on Ubuntu Server
How to Override REST Authentication