How to take instant backup using CLI in Magento 2

In Magento 2, You can take an instant backup of your store using the command line Interface (CLI). This backup includes the database and file system.

Before you proceed with any actions on your Magento 2 store, it’s crucial to ensure that the “Enable Backup” setting in the backend is set to “Yes.” To configure this setting, follow these steps:

Follow these steps to take a quick backup in Magento 2 using the CLI:

Login to your Magento admin panel. click on “Store” menu and select “Configuration”.

Then choose Advanced left sidebar and click “System” then click Backup settings

Access Your Server: Log in to your server using SSH.

Navigate to Your Magento Root Directory: Use this cd command to navigate to your Magento 2 installation directory. This is typically located in your web server’s document root folder. For example:

cd /opt/bitnami/apps/magento/htdocs

Magento 2 provides a command to take backups. You can use the following command to take an instant backup:

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

Here’s we explain each options:

–code: This option includes the code and application files in the backup.
–media: This option includes the media files (e.g., images, product images) in the backup.
–db: This option includes the database in the backup.

You can choose to include all three options, as shown in the example above, or omit any of them based on your requirements.

Monitor Backup Progress: Magento will start the backup process, and you’ll see progress messages on the screen. It may take some time, depending on the size of your store.

Verify the Backup: After the backup process is complete, you can find the backup files in the var/backups directory within your Magento root. You can access these files to download or restore your backup if needed.

That’s it! You’ve successfully taken an instant backup of your Magento 2 store using the CLI. It’s good practice to regularly back up your store to ensure that you can recover your data in case of any issues or disasters.

Leave a Reply

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