azuremagento

Create and restore application backups

Magento 2.3 and later no longer include built-in backup functionality. Therefore, backup (and restore) operations must be performed manually using external tools.

Backup

The steps below explain the process of backing up the Magento database and media files. They do not cover the process of backing up the Magento application itself or any installed extensions. Extensions, if any, should be reinstalled using the Magento control panel when the backup is restored.

The steps below assume that:

  • You have the administrator password for the Magento control panel.
  • You have the root password for the database server.
  • You are able to log in to the Magento server console.

To obtain a list of installed extensions, follow these steps:

  • Log in to the Magento control panel as an administrator.

  • Navigate to the “System -> Web Setup Wizard -> Extension manager” page.

  • Note the list of installed plugins, together with their version numbers.

    Magento installed extension list

Then, follow the steps below to back up the Magento database and media files:

  • Put Magento into maintenance mode:

      $ sudo magento-cli maintenance:enable
    
  • Backup the bitnami_magento database as described in the Create and restore MySQL/MariaDB backups page.

  • Execute the commands below to back up the Magento media directory:

      $ sudo tar -czv -C /opt/bitnami/pub -f /tmp/magento_media.tgz media
    
  • Disable maintenance mode:

      $ sudo magento-cli maintenance:disable
    

At this point, two backup files have been created: backup.sql for the database backup, and /tmp/magento_media.tgz for Magento media files.

You should now download or transfer these files to a safe location. At the same time, make a note of the administrator password, as this will be needed at the time of restoring the backup.

Restore

The steps below assume that:

  • You have installed the Bitnami Magento stack.
  • You have the administrator password for the Magento control panel.
  • You have the root password for the database server.
  • You are able to log in to the Magento server console.

Before proceeding with the steps below, if your original installation included additional extensions, navigate to the Magento control panel and reinstall any extensions needed using the extension manager and the list made at backup time.

To restore a backup, follow these steps:

  • Transfer the backup files to the Magento server.

  • Stop all services:

      $ sudo /opt/bitnami/ctlscript.sh stop
    
  • Restore the bitnami_magento database backup as described in the Create and restore MySQL/MariaDB backups page.

IMPORTANT: After performing this step, the Magento administrator password will be reset to the value in the backup file.

  • Uncompress and restore the media backup:

      $ sudo tar -xzvf /tmp/media.tgz -C /opt/bitnami/magento/pub
    
  • Restart all services:

      $ sudo /opt/bitnami/ctlscript.sh start
    
  • Run the Magento indexer to update Magento with the new data:

      $ sudo magento-cli indexer:reindex
    

Your Magento database and media files should now be restored.

NOTE: Remember that you will now only be able to log in to the Magento control panel using the previous administrator password. You should log in and change this password as soon as possible.

Last modification February 9, 2023