If you are a Drupal website owner, developer, admin or a user, you should already know that Drupal 10 is coming soon - June 2022. And that’s just over a year to go! The advantages of migrating to the most updated version of a software are priceless. More so when you have a community of open-source enthusiasts working towards a single goal of improving Drupal every single day, you must trust that migrating to the latest version of Drupal is going to be one of the best decisions you will make.

If you’re still on Drupal 7, it’s about time to migrate to Drupal 9. There are many ways of migrating your website from Drupal 7 to Drupal 9). Here’s a no-frills guide to migrating your Drupal 7 website from a database source.

Migration from Database Source

What is a Drupal Migration?

Migration is a movement of content from Drupal 7 to Drupal 9. This includes configuration (content types, vocabularies, user roles, file types, image styles, etc.) and contents (users, nodes, paragraphs, taxonomy terms etc.)

Drupal 7 to Drupal 9

The ETL Process

No matter what your source or destination is for a migration, a Drupal migration will follow the ETL process or the Extract – Transform – Load process. The first step is the Extraction step where the data is extracted from the source plugin. The next step is the Transformation step where the extracted data is processed according to the requirements by the process plugin. And lastly, the Loading step where the data is loaded into the storage by the destination plugin.

Process Plugin

Migration Plugins and Modules

    1. Source plugin

A set of data, called row from the source. They help fetch data from the source like a database, CSV, XML or JSON.

    2. Process plugin

Row data will be processed and transformed as required. It describes how the destination is to be built from the source data.

    3. Destination plugin

Once processed, the transformed row is saved to the destination in the Drupal site.

Modules Required

  • Migrate Module – Contains APIs to migrate content and configuration to Drupal 9.
  • Migrate Drupal Module – Helps in migrating content and configuration from a Drupal source site to Drupal 9.
  • Migrate Drupal UI Module – A user interface to perform the migration.
  • Migrate plus Module – Provides capabilities to transform source data and APIs for grouping migrations.
  • Migrate tools Module – A contributed module that offers extended drush commands to manage Drupal 9 migrations. 
  • Drupal upgrade – A contributed module used to create the migration YML scripts.

How do I Migrate to Drupal 9: The Groundwork 

Now that we have a fairly good understanding of some of the basic migration concepts and have installed the basic modules needed for the migration (as discussed above), let’s look at a few simple steps to follow before actually commencing a Drupal 7 to Drupal 9 migration:

  • Audit the Drupal 7 site for contributed modules. Many of the fields in the Drupal 7 content types will depend on contributed modules. So, we will need to check for those modules and install the same in Drupal 9.
  • Install the contributed modules if it is not incorporated in Drupal 9 core.
  • Install the supportive core modules like revisions, translations, etc. if needed.
  • Have the Drupal 7 database and files accessible by the Drupal 9 instance.
  • Select the method of migration Bulk or Individual carefully based on the complexity of the site.

Connecting to the Drupal 7 Database

Now we will need to connect to the source database of the Drupal 7 website. For that, we will need to add the source database information in the Drupal 9 settings file.

Go to settings.php file of your Drupal 9 site and add the database with migrate key and run this command:

drush migrate-upgrade --configure-only --legacy-db-key=migrate --

Or you could also directly configure using this URL:

drush migrate-upgrade --configure-only 
--legacy-db-url=mysqli://[email protected]:33067/drupal7_db --

The above commands will generate migration YMLs based on the Drupal 7 configuration and contents. It will not start the migration as we added the option “--configure-only”.

Drupal 7 to Drupal 9 Migration - Bulk import

To perform a bulk migration on all configurations and contents to Drupal 9, you will need to execute these commands :

drush migrate:import --tag=Configuration --execute-dependencies

This will run all the configuration migrations by running the dependencies at first.

drush migrate:import --tag=Content --execute-dependencies

This command will run all the content migrations by running the dependencies at first. Please Note: The migration order is important.

Please Note: The migration order is important.

Drupal 7 to Drupal 9 Migration - Individual import

Sometimes, you might not want to migrate ALL of your content of configurations at one shot. You can then opt to migrate them individually. However, you will need to keep in mind to migrate them in order.

  1. Configuration: User roles, vocabularies, content types, image styles, fields, field instances etc.
  2. Content: Files, paragraphs, Users, terms, nodes, etc.

Migration Tools drush Commands

The Migration Tools module (as discussed previously) is a contributed module that gives you some tools and commands that will help you during a migration. Some of the commands include:

  • drush ms - Migration status
  • drush mim <migration> - Migration import

                      Imports the data from Drupal. We can also run the import with a limit. For example: drush mim --limit=10

  • drush mr <migration> - Migration rollback
  • drush mmsg <migration> - Migration message

                     Shows the captured message (error or notice) after the migration import.

Final Thoughts

A Drupal 7 to 9 migration can be easily performed with Drupal’s core migrate modules itself. Other contributed modules like Migration Tools will provide more flexibility while running the migrations. Core migration API is extremely powerful and we can migrate any kind of content provided by the ETL plugins. Drupal’s flexibility also allows us to create our own custom plugins to achieve any custom migrations. Need assistance in migrating your Drupal 7 website to Drupal 9? We would love to help!


Contact us