Bitnami How-To Guides for AWS Cloud

Migrate Data From One Drupal Instance to Another


There are two different ways to upgrade and maintain your Drupal installation:

  • Use the built-in upgrade feature. Read detailed instructions for this.

  • Migrate your installation to a new server instance with an updated version of the application and/or underlying components.

This guide describes the second option. We recommend that you do this from time to time to make sure that you not only have the best and latest version of Drupal, but also have the latest (and most secure) versions of Apache, MySQL and other software that Drupal runs on. We regularly refresh the images available in the Bitnami library to make sure that you always have access to the most up-to-date software.

To migrate Drupal data from an instance to a new instance running a later release of the Bitnami Drupal Stack, follow the steps below.

Step 1: Backup existing data

Back up your existing Drupal data by following the steps below:

  • Log in to the server console.

  • Execute the following command to create a backup of the current database. In this example, the database is named bitnami_drupal8. Replace this with the name of the database you wish to export.

    $ mysqldump -u root -p bitnami_drupal8 > backup.sql
  • Enter the database password when prompted. Refer to the FAQ for information on obtaining the database password.

    This will produce a backup.sql file in the current directory with the content of the selected database. Store this file carefully, as you will need it in the next step.

  • Uploaded images, themes or plugins are saved in the sites/ directory. If you want to preserve this data, create a backup by issuing the following commands:

    $ cd /opt/bitnami/apps/drupal/htdocs
    $ sudo tar -czvf /home/bitnami/sites_backup.tar.gz sites
  • Create a backup of the configuration files. If Drupal was configured to run at the root URL, you may have modified the Drupal configuration file at /opt/bitnami/apps/drupal/conf/drupal.conf. In this case, create a copy of this file as well:

    $ cp /opt/bitnami/apps/drupal/htdocs/.htaccess /home/bitnami/htaccess.backup
    $ cp /opt/bitnami/apps/drupal/conf/drupal.conf /home/bitnami/drupal_backup.conf
  • If you have customized the php.ini, my.cnf, httpd.conf or any other configuration files, back up these files as well.

You now have all of the required data to migrate your Drupal site to a new instance.

Step 2: Copy and restore data on the new instance

To copy and restore data from the old instance to the new one, complete the following steps:

  • Copy the files backed up in the previous step to the new instance, using SFTP or SCP. For more information, refer to the FAQ.

  • Save a copy of the new /opt/bitnami/apps/drupal/htdocs/sites/default/settings.php file, which contains the database settings:

    $ cp /opt/bitnami/apps/drupal/htdocs/sites/default/settings.php /home/bitnami
  • Populate the new application database with data from the previous installation. This step requires administrator permissions:

    $ sudo su bitnami
    $ mysql -u root -p bitnami_drupal8 < /home/bitnami/backup.sql
  • Enter the database password when prompted. Refer to the FAQ for information on obtaining the database password.

  • To restore previously-installed plugins, themes or uploaded files, uncompress the backup file created previously:

    $ sudo tar -xzvf /home/bitnami/sites_backup.tar.gz -C /opt/bitnami/apps/drupal/htdocs
  • Restore the configuration files:

    $ cp /home/bitnami/htaccess.backup /opt/bitnami/apps/drupal/htdocs/.htaccess
    $ cp /home/bitnami/drupal_backup.conf /opt/bitnami/apps/drupal/conf
    $ sudo cp /home/bitnami/settings.php /opt/bitnami/apps/drupal/htdocs/sites/default
  • Restore the Apache configuration file if necessary from backup.

  • Restart the servers:

    $ sudo /opt/bitnami/ restart
  • Drupal may require the database schema to be upgraded. In the Drupal administration panel, browse to the “Report -> Status” section and run the database update script if necessary.

    Drupal upgrade

Your content should now be fully migrated and usable on the new Drupal instance.

Last modification September 8, 2018