A Simple Drupal 7 to Drupal 8 Migration

Image
Illustration depicting migration of data from Drupal 7 to Drupal 8

Editor's note: There have been some changes to Migrate in core as of Drupal 8.1.0 and Migrate Plus is now joined by Migrate Tools. To learn more about more recent migration practices read Custom Drupal-to-Drupal Migrations with Migrate Tools. To learn how to upgrade/migrate to Drupal 8, follow our full Drupal 8 Migration Guide.

It probably won't be much of a surprise to hear that there's a lot of excitement around these parts about Drupal 8. With the release candidates coming out recently and November 19, 2015 announced as the official release date, we've been putting a lot of work into our curriculum and recording new tutorials.

The developer in me has been itching to give it a try on a "real" project. The Drupalize.Me site itself is pretty complex: e-commerce (with recurring billing), video delivery, and piles and piles of content. Suffice it to say it's not a prime candidate for migration right now. Our blog however, is definitely a better prospect. Justin has a great new design for us. Amber has mentioned how much she'd like the new Drupal 8 authoring tools. The blog is relatively straight-forward which makes it a great way for our whole team to start using Drupal 8. So, as we start to think about upgrading our blog the first thing we're going to have to think about is data migration. Let's take a look at Migrate module, that's now part of Drupal core, and see how much work we might have ahead of ourselves.

Resources for Drupal-to-Drupal migration

My first stop on this adventure was to Drupal.org to check out the Migrate module's documentation. There are now four migration-related modules to know about:

  • Migrate: The core API
  • Migrate Drupal: Provides the classes needed to migrate Drupal to Drupal 8.
  • Migrate Upgrade: Provides a simple user interface for running migrations from Drupal 6 or Drupal 7. There is ongoing work to include more of this UI in core.
  • Migrate Plus: This is the current home for the pieces of Drupal 7's migrate functionality that didn't make it into core. It's home to things like plugins that support XML, CSV, and JSON data sources as well as proprietary databases like MS SQL or Oracle. This module includes another, Migrate Tools, which provides additional UI and drush commands for managing migrations. Note Migrate Plus is being split up into several smaller modules early next week.

In addition, core modules that have migration paths written will have migration plugins within their own directories (see the user or taxonomy module for examples).

The next resource I visited was the Executing a Drupal 6/7 to Drupal 8 upgrade handbook page on Drupal.org. As this page points out, the bare bones of what you need to test a migration are:

  • A local environment for your source site
  • A local Drupal 8 site
  • The Migrate Upgrade module
  • Drush 8.x (or dev)

Once you have these basics in place you can proceed with a migration from either the UI or using Drush.

A cautionary tale

Drupal 8 is still in the release candidate phase (as of the time of writing this post), and there are a list of known issues with the Drupal-Drupal migrate path as well that will likely persist into 8.0.0. Probably the biggest issue for this particular migration is that Views are not yet being migrated automatically. The other issue I ran into was with the input formats on our current site. One of our input formats depends on a custom module that hasn't been ported to Drupal 8 yet.

Most problems you'll run into attempting a migration right now will fall into one of these two categories:

  • missing migration paths
  • contributed modules that need to be ported to Drupal 8

Before actually starting a migration, it's probably a good idea to identify the contributed modules you're using on your site and see which ones have Drupal 8 versions already available to test. As for the migration paths, this is one place the Migrate UI comes in really handy, as you can see in this screenshot:

Image
Available migration paths

Screenshot: Available migration paths

Prepare to migrate

To get started, on my local Drupal 8 site I've enabled the Migrate, Migrate Drupal and Drupal Upgrade modules. With these modules enabled, we can now visit the upgrade form (at the path /upgrade). Here you'll be presented with another warning about not using your live site as the data source, as well as some other reminders about enabling modules and database access.

Next you'll be asked to specify the credentials and location of your source database and files. After entering that information you'll be presented with a list available and missing migration paths. This list should give you a pretty good indication of what might be missing, and how much work you'll need to do in order to get your new Drupal 8 site really ready for a migration.

Image
Missing migration paths

Screenshot: Missing migration paths

Limitations of Migrate's UI

If you proceed with a migration here from the UI, migrate will trigger an import of all of the available migrations. On my first attempt with a migration going this route I ran into a few issues. You can imagine that migrating all of the users, content and configuration for a site of this size takes a bit of time. Indeed, the first attempt lead to a batch failure during the user import process. I was (eventually) able to complete the migration by rerunning it from the web UI a handful of times.

Improve the migration process with Drush

Since the documentation goes out of the way to suggest using Drush to run migrations, I figured that was also worth a shot. The Migrate Tools module (bundled as part of Migrate Plus) provides several helpful Drush commands:

  • migrate-import (mi): Perform one or more migration processes.
  • migrate-manifest: Execute the migrations as specified in a manifest file.
  • migrate-messages: View any messages associated with a migration.
  • migrate-reset-status: Reset a active migration's status to idle.
  • migrate-rollback: Rollback one or more migrations.
  • migrate-status (ms): List all migrations with current status.
  • migrate-stop (mst): Stop an active migration

When I run migrate-status, I get a list of all of the available migrations, status, total number of records, number imported and unprocessed and information about the last import. We can use migrate-import to run one particular migration. Using Drush to selectively run the migrations I needed for our blog dramatically sped up the total migration time for this particular site. Going forward I'll be using Drush, as the Drupal.org documentation recommends, rather than the UI to trigger migrations.

Create a migrate manifest YAML file

Once you've identified the migrations you're interested in, you can create a migrate manifest YAML file and use that to run a particular set of migrations. Documentation on drupal.org can help walk through the details of creating this manifest file. Once a manifest has been created the migrate-manifest command will run a migration for each item specified in the file.

Image
Content migrated to Drupal 8

Screenshot: Content migrated to Drupal 8

Impressions so far

I've been really impressed by how far along, and how polished the Drupal 8 migration process is already. There are definitely a couple of contribute modules we'll need to evaluate in order to have a fully working Drupal 8 blog, but I was able to migrate the bulk of our content without writing a single line of code.

In retrospect, as we continue to evaluate moving our blog to a Drupal 8 site I now need to go back and clean up the source site I use with Migrate. If we're going to split the blog off into a separate Drupal 8 site we won't need all of the content types or much of the other site configuration from the main Drupalize Me site. This will eliminate cruft from our new blog, and speed up the actual migration process itself. We'll also need to check in on a couple of key contributed modules, and rebuild a handful of Views (since they do not have a working migration path right now).

With the help of Migrate, the process of moving our blog to Drupal 8 is a lot less painful than I would have anticipated. Kudos to all the hard work that's gone into the Migrate collection of modules! With the official release of Drupal 8 right around the corner, maybe it's time to try migrating your site?

Comments

Thank you very much. It helps a lot to understand the migration process of Drupal 8. Keep posting such great experiences.

This worked pretty well overall. Most content was moved successfully from Drupal7 to Drupal8.

One problem though: it seems the upgrade lost the associations between a linked file or image and the node. Haven't been able to figure that out and definitely don't want to do by hand.

Any suggestions?

Hi Thomas,

Migrating files probably depends a bit on the particular configuration of your site, but there are two things that come to mind that might be worth looking in to.

If you're using entity references to point to files, you probably want to keep an eye on https://www.drupal.org/node/2611066 which includes a patch where that upgrade path is being worked on.

If you're working with private files, there's a patch to test for that upgrade path here: https://www.drupal.org/node/2505283.

Hopefully one of these will help you out. Cheers!

Can I get a little more information on the preparation of the source file? Do I need to create a copy of the live site and put it on to the same server as the D8 site? How can I set the live site directly as the source file?

Thanks.

Hi Melvina,

You should definitely not attempt migrations on a live site. You should create a copy of your live site, along with a drupal 8 site, to perform your migrations. We will have a tutorial going in to more detail soon.

Hi there, I want to upgrate my drupal 7 site to drupal 8.
But I'm so confuse how can i start how can i figure out this.
Actually I'm a blind web developer working with an organisation called Blind Help Project [BHP] and our ame is to help out the visually impaired cummunity all over the world in technology.
So please can you help me and tell me the easyest method to perform this huge migration?
Looking forward to your response.
Regards!

Hi Abdullah,

Probably the best place to get started with a migration is our Upgrade to Drupal 8 topic page. This will help point you towards tutorials on our site (and elsewhere) with plenty of information to help you plan and execute a Drupal 7 to Drupal 8 migration.

Cheers,

Blake

I migrated using modules via web, super migrated content type, taxonomy, etc... but no import o uploading images from s3 in Drupal 7 to s3fs in Drupal 8 configurated. How do that?
Somebody know about that.
Thanks

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more