nativeInstallermagento

Migrate a Magento installation

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). Learn more.

There are two important steps when migrating a Magento Stack: create a backup of your system and database on the old server, and restore it to the new one. To make this process easier, divide them into four sub-steps.

Export the Magento installation files and database

The first step you need to follow is to create a full backup both of the Magento installation files and its database. Once you have obtained the backup files, export and save them to a safe location. In the old machine you have installed Magento, perform the following:

  • Create a system backup using the Magento admin interface section. Remember to select the “System Backup” option.

    TIP: You can enable the maintenance mode while creating the backup. Visitors will see a “Service Temporarily Unavailable” message in their web browsers instead of the store.

    • Once the backup has been created, you will see your backup in the list of available backup files. Select the one you have created and click on the tgz link to download it.

    Download the Magento backup file

  • Create a database backup. You can do this manually or with phpMyAdmin. If you use phpMyAdmin, export it as an .sql file.

  • Download the resulting .sql file. If you created the database backup using phpMyAdmin, the file was automatically downloaded. If you created the database backup manually, download the file from your server with SFTP.

Upload the Magento installation backup file

In this step, you just need to upload the Magento installation backup file to the machine where you have installed the new Magento. Upload the file to the new server with SFTP. Then, move it to the installdir/apps/magento/htdocs/ directory.

Import the database

Follow these instructions to import and restore the database backup into the new Magento installation:

  • Upload the .sql file to the new server.

  • Stop all the services:

    $ sudo installdir/ctlscript.sh stop
    
  • Restart only the database as follows:

    $ sudo installdir/ctlscript.sh restart mysql
    
  • Restore the database by following these instructions.

Substitute pub/ and var/ directories

To complete the migration of your old Magento installation to the new one, you need to replace some directories and delete some others in order to save space and clear some useless data.

  • Change to the installdir/apps/magento/htdocs/ directory and remove the pub/ and var/ folders:

    $ cd installdir/apps/magento/htdocs/
    $ rm -rf var pub
    
  • Uncompress the system backup .tar file. To do so, execute the following command (replace the BACKUP_FILE placeholder with the name of your backup file):

    $ sudo tar xzpf BACKUP_FILE
    
  • Remove the var/cache, var/session, var/report and var/log directories:

    $ cd var
    $ rm -rf cache session report log
    
  • Stop the database service:

    $ sudo installdir/ctlscript.sh stop mysql
    
  • Open the installdir/apps/magento/htdocs/app/etc/env.php file, check the password, host, port and user values and replace them with the values of your new Magento installation.

  • Restart all the services:

    $ sudo installdir/ctlscript.sh restart
    

Now, you should be able to access the new Magento admin panel using the password of your old server. The migration of your old Magento installation has been completed.

Last modification September 11, 2018