awsdrupal

Bitnami How-To Guides for AWS Cloud

Migrate Data From One Drupal Instance to Another

Introduction

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. It is highly recommended to do this from time to time to make sure that you have both the latest version of Drupal and the latest (and most secure) versions of Apache, MySQL, and other software that Drupal runs. Bitnami regularly refreshes the images available in the Bitnami library to ensure 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 database and server configurations

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 to learn how to obtain 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.

  • If you customized the php.ini, my.cnf, httpd.conf, or any other configuration files, back up these files as well. 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 follows:

      $ cp /opt/bitnami/apps/drupal/conf/drupal.conf /home/bitnami/drupal_backup.conf
    

Step 2: Backup existing Drupal application data

Create a backup of the uploaded images, themes, or plugins that are saved in the sites/ directory:

    $ cd /opt/bitnami/drupal/
    $ sudo tar -czvf /home/bitnami/sites_backup.tar.gz sites
    $ cp /opt/bitnami/drupal/.htaccess /home/bitnami/htaccess.backup

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

Step 3: 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/drupal/sites/default/settings.php file, which contains the database settings:

      $ cp /opt/bitnami/drupal/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/drupal
    
  • Restore the configuration files:

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

  • Restart the servers:

      $ sudo /opt/bitnami/ctlscript.sh restart
    
  • Upgrade the Drupal database schema: In the Drupal administration panel, navigate to the “Report -> Status” section and run the database update script.

    Drupal upgrade

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

Last modification February 9, 2023