Manually Migrate

Migrate a Drupal 8 Site to Drupal 9 on Pantheon

Contributors: Sarah German, Greg Anderson.

Discuss in our Forum Discuss in Slack

In this doc, you'll create a new Drupal 9 site and migrate the code from an existing Drupal 8 site to it.

Will This Guide Work for Your Site?

You might encounter significant issues if the site does not match these requirements.

Before you continue, confirm that your site meets the following:

  • The site has the Pantheon drops-8 repo in its Upstream.

    • The site can not be set to use an empty Upstream.
  • The site does not use a nested docroot.

  • The site does not use Pantheon Search.

  • The site does not use another package and library manager like Ludwig.

Prepare the Local Environment

  1. Review our documentation on Git, Composer, and Terminus, and have them installed and configured on your local computer. Pantheon requires Composer 2 at minimum.

    • Mac users can use Homebrew to install Git, Composer, and PHP 7.4, along with their required dependencies. Restart the shell or terminal environment after entering the following command:

      brew install git composer php@7.4
    • Windows users can install Composer and Git, and may need to install XAMPP or similar to satisfy some dependencies.

  2. Install the Terminus Site Clone plugin.

  3. This guide uses several commands that depend on the site name in the local command line environment.

    To make this easier, set the temporary variable $SITE in your terminal session to match the site name. Read the steps further in this doc to see which sites should be aliased (it may be more than one), then replace anita-drupal in this example:

    export SITE=anita-drupal && echo "New alias set as $SITE"

This doc uses the following aliases:

  • Alias: D8_SITE
    • Site Name: best-drupal8-site-ever
  • Alias: D9_SITE
    • Site Name: best-drupal9-site-ever

Create a New Drupal 9 Site

  1. Use this link to create a new Drupal 9 Integrated Composer site from the Upstream: On the Create Your Pantheon Site page:

    • Enter a name for the site.

    • Choose an Organization if applicable.

    • Choose a region for the site. Click Continue.

    After you click Continue, it will take several minutes for the platform to set everything up.

  2. In the Dev tab on the Dashboard, set the site's Development Mode to SFTP.

  3. Still in the Dev tab, click Visit Development Site and follow the prompts to complete the CMS installation.

  4. Return to the Dev tab, set the site's Development Mode to Git, and clone the site locally.

  5. In your local terminal, from the project root directory, run composer install.

Migrate the Drupal 8 Code to the Drupal 9 Site

  1. From the local Drupal 9 site's directory, use Terminus to retrieve the D8 site's Git URL:

    terminus connection:info $ --field=git_url
  2. Add the Drupal 8 site as a remote repository called existing-8. Use the URL retrieved in the previous step:

    git remote add existing-8 ssh://
    git fetch existing-8
  3. Copy over exported configuration from the original site. From your D9 site, run the following commands:

    git checkout existing-8/master -- sites/default/config
    git mv sites/default/config/* config/
    git commit -m "Add site configuration."
  4. Compare your current pantheon.yml file with the new D9 pantheon.upstream.yml:

    git diff existing-8/master:pantheon.yml pantheon.upstream.yml
  5. If you have customizations in your D8 site's pantheon.yml that you want to keep for D9 (e.g., a Quicksilver script or site-specific protected web paths), copy pantheon.yml over:

    git checkout existing-8/master -- pantheon.yml
    git commit -m "Update pantheon.yml."
  6. Copy over any Quicksilver scripts referenced in pantheon.yml:

    git checkout existing-8/master -- private/scripts
    git commit -m "Add Quicksilver scripts."
  7. List contrib modules and themes on your D8 site:

    terminus drush $ -- pm:projectinfo --status=enabled --fields=name,version --format=table
  8. Then use Composer on your D9 site to add these there:

    composer require drupal/ctools:^3.4 drupal/redirect:^1.6 drupal/token:^1.7
    git add composer.*
    git commit -m "Add contrib projects."
  9. Copy over any custom modules or themes from your D8 site:

    git checkout existing-8/master -- modules/custom themes/custom
    git mv themes/* web/themes
    git mv modules/* web/modules
    git commit -m "Add custom projects."
  10. Check settings.php for any customizations to copy over:

    # Fetch your D8 settings file.
    git show existing-8/master:sites/default/settings.php > web/sites/default/original-settings.php
    # Check for any customizations (if this returns nothing, you can move on to the next step).
    # Copy what you need over to web/sites/default/settings.php, and commit as needed.
    diff -Nup web/sites/default/settings.php web/sites/default/original-settings.php
    # Remove the original copy.
    rm web/sites/default/original-settings.php
  11. Copy your files and database from your D8 site to the D9 site:

    terminus site:clone $ $ --no-code --no-destination-backup --no-source-backup
  12. Push the D9 codebase from your local machine up to Pantheon:

    terminus connection:set $ git
    git push origin master
  13. Run database updates:

    terminus drush $ -- updatedb
  14. Review the site, then proceed to launch using the Pantheon Relauch documentation.