How to exploit all commands in Magento 2 (CLI) part 6

Here I will show you how  to exploit all commands in Magento 2 (CLI)

Part 6: Backup and roll back Magento

In this article we going to discuss about Magento command line CLI

Everyone knows Magento 2 has a powerful command-line interface tools (CLI). It permits you to complete task including installation, configuration, database backups, compiling LESS etc. Here I will explain you how to Backup and roll back Magento using command-line. Before starting this guide please, refer our previous guidelines

1. Backup Magento

  • To create backup of your Magento
php bin/magento setup:backup [–code] [–media] [–db]

This command will process the following mission:

  • Set Magento store in Maintenance mode
  • Build backup files then its store it at [Magento_folder]/var/backups
  • Take Magento store out of maintenance mode.

The following command for backup only Magento database:

php bin/magento setup:backup –db

2. Rollback Magento

  • You can rollback your Magento from the backup that build in the past. To view the list of backup, use the following command:
php bin/magento info:backups:list
  • Then rollback one of the previous backups
php bin/magento setup:rollback [-c|–code-file=”<name>”] [-m|–media-file=”<name>”] [-d|–db-file=”<name>”]
  • The following command will roll back a db backup named 1434133011_db.gz
    php bin/magento setup:rollback -d 1434133011_db.gz
  • Then you will get the result as:
[SUCCESS]: Database rollback completed successfully.

Please set file permission of bin/magento to executable

Disabling maintenance mode

I hope the following guidelines will defines you how to backup or roll back in Magento 2 CLI


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *