Migrating from Drupal 6 to Drupal 8 Like a Boss

Migrations are not always a walk in the park and, as we have already seen in previous articles, they may need a lot of planning.

a

If we are talking about moving from big versions (namely Drupal 6 or Drupal 7 to Drupal 8), just talking about infrastructure can cause you to start to sweat.

Even in Drupal itself, the truth is (or was until recently) migrations were not fully stable and they could give you more than a headache. On top of that, building the local infrastructure is a necessary pain, where you can lose a lot of precious time that you'd rather be dedicating to the migration itself.

Well, all of that was true a year, or even months ago… but not anymore.

First, core Drupal 8 migration is pleasantly stable now, and the process itself can be -- for many cases -- a walk in the park. I've been following the evolution since it was announced, and it has evolved from a painful process where you would end up with a site where lots of things were broken (images and files, taxonomies, modules that were not yet supported, etc.) to where we are nowadays, where everything works just like magic. At least for simple sites like blogs, content types without excessively sophisticated fields or dependencies, and so on.

Second, we have tools like DDEV that have transformed the process of building your local environments into an absolute joy.

So let’s go for it!  I’ll use my personal site, alexmoreno.net as migration example.

Step 0. Install DDEV

First thing you are going to need is to install DDEV. Simply go to

https://github.com/drud/ddev

And just follow the setup steps. The installation instructions are here:

https://ddev.readthedocs.io/en/stable/#installation

Note that I’ve chosen DDEV because, as we are going to see, it makes the process really simple. But that should not stop you from trying the same, or very similar, process using Lando or Docksal for example. In fact if you can do it please let us know how it went :-).

Step 1. Configure your old Drupal site locally.

First things first, we'll need to get the source, or get the latest version of the core, for the current version of whatever our site is using (Drupal 7, Drupal 6...). And as always, make sure your site has both core and contributed modules updated to the most recent versions.

https://www.drupal.org/project/drupal

Also get the latest version of whatever the latest Drupal 8 is at that moment, as we'll be running both in parallel in the next step. I like to organize both in folders like this:

/path/moreno-d6 
/path/moreno

While the second folder contains the goal, Drupal 8, the first one is self explanatory: my old blog in Drupal 6 (or 7 if that's your case).

Step 2. Open your old site

Then let's fire up the Drupal 6/7 version that we want to migrate to Drupal 8. We'll go to the folder where we have the sources, those that we have just downloaded, and we'll follow the normal steps we execute to start any new project in DDEV.


ddev config
ddev start

At the end we should see something like this:

Successfully started moreno-d6 Project can be reached at http://moreno-d6.ddev.local, https://moreno-d6.ddev.local, http://127.0.0.1:32791

The magic about DDEV is that it'll detect your Drupal version and it will take care of everything else for you. From php versions, databases, routing, the http engine, etc. Just like that, what is not to love? Next we won't be following the next steps in DDEV creating a new project. Instead we'll import the database from the current projector site (the one that we want to migrate from).

ddev exec drush sql-cli  < ../morenodotnet.sql

Depending on your site you may need to set up a few things, making sure all is running and working. In my case, for example, I had some modules missing and a theme, so I scp’ed everything (ftp’ed or whatever - remember composer didn't exist yet in Drupal 6) into the DDEV folder. Once everything looks like its working, and we are happy with the old site running in DDEV, we can move on to the next step.

Step 3. Configure your new (Drupal 8) site

Which is configuring a new Drupal 8 site. We'll repeat the same steps, but this time in the Drupal 8 folder, and finishing the install with drush site-install:

ddev config
ddev start
ddev exec
drush site-install --account-name=admin --account-pass=admin 

 

Unbelievable, right?

I told you the process is simple, but it never ceases to amaze me how simple it is nowadays. I would have spent 30 minutes or more on this in the past -- just preparing the machine, php, apache, MySQL…

It's worth it to note that all this has been done in these simple steps.

Apart from that, please please please, don't use admin/admin as I have. Replace them with a strong user/password combination.

Step 4. Ready, Steady, Migrate!!

Now let's move to the migration itself.

We are going to need a few tools.

composer require drupal/migration_tools
composer require drupal/migrate_plus
# And lets enable them in Drupal
ddev exec drush en -y migration_tools, migrate_drupal_ui, migrate_drupal, migrate 

Thunderbirds, it's all systems go!

We’ll use the Drupal Migrate UI, so this is going to be easy. But if you opt for Drush, it will be equally easy. Just head to the Drupal 8 upgrade url:

https://moreno.ddev.local/upgrade

Then, the important parameters to use here are the url or host, and the public files folder. The host will be the DDEV machine name. You can get this from docker ps:

$ docker ps

CONTAINER ID        IMAGE         COMMAND CREATED             STATUS PORTS                                                                      NAMES

5d85d82d8b18        drud/ddev-router:v1.4.0      "/app/docker-entrypo…" 12 hours ago        Up 12 hours (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8025->8025/tcp, 0.0.0.0:8036->8036/tcp   ddev-router

c8c0cc9e3340        drud/ddev-webserver:v1.4.0   "/start.sh" 12 hours ago        Up 12 hours (healthy) 0.0.0.0:32791->80/tcp, 0.0.0.0:32790->8025/tcp                                             ddev-moreno-d6-web

70f3e4a4ed53        drud/phpmyadmin:v1.4.0       "/run.sh phpmyadmin" 12 hours ago        Up 12 hours (healthy) 0.0.0.0:32789->80/tcp                                                                      ddev-moreno-d6-dba

ac0a377b9b3c        drud/ddev-dbserver:v1.4.0    "/docker-entrypoint.…" 12 hours ago        Up 12 hours (healthy) 0.0.0.0:32788->3306/tcp                                                                    ddev-moreno-d6-db

413227d3eea1        drud/ddev-webserver:v1.4.0   "/start.sh" 21 hours ago        Up 21 hours (healthy) 0.0.0.0:32787->80/tcp, 0.0.0.0:32786->8025/tcp                                             ddev-moreno-web

1e00a0636051        drud/phpmyadmin:v1.4.0       "/run.sh phpmyadmin" 21 hours ago        Up 21 hours (healthy) 0.0.0.0:32785->80/tcp                                                                      ddev-moreno-dba

dc4ea56ad25c        drud/ddev-dbserver:v1.4.0    "/docker-entrypoint.…" 21 hours ago        Up 21 hours (healthy) 0.0.0.0:32784->3306/tcp                                                                    ddev-moreno-db

 

So it would be:


Drupal version to migrate from: D7
db host: ddev-moreno-d6-db
user: db
password: db

public files: https://moreno-d6.ddev.local/

Note that you could also use your current site for the public files, for example: https://alexmoreno.net/. Sometimes this may help to debug issues, wrong migrations, etc.

Press next, wait a few minutes, and that's pretty much it.

In your new Drupal 8 site you'll have to add a new theme, maybe some new modules, customize a bit, and, once you are happy with the results, you are good to go. Export your db like this:

ddev exec drush sql-dump  --result-file=morenod8.sql

 

And then deploy, maybe in a Kubernetes environment if you have the time for that.

Otherwise, I'd recommend a hosting platform like Acquia Cloud, where everything is optimised and monitored for you -- in case you need something more robust and/or you don't have the time to maintain the machines by yourself.