Posted on
Upgrade from Drupal 7 to Drupal 8 using Drush

Upgrading from Drupal 7 to 8 can be quite a daunting task. Here are some hints and tips to get you on your way!

Drupal and Drush

Unless your site is very straightforward, you are going to benefit from using drush. First off, you will need to install the appropriate modules - here is a quick list:

  • migrate_file
  • migrate_plus
  • migrate_manifest
  • migrate_tools
  • migrate_upgrade

Database Migration

Next, add your legacy database to your drupal 8 settings.php file in this format

$databases['default']['default'] = array (
  'database' => 'drupal8db',
  'username' => 'user',
  'password' => 'password',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

$databases['migrate']['default'] = [
  'database' => 'drupal7db',
  'username' => 'user',
  'password' => 'password',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
];

Now you are ready to start, open up a terminal window and try out these commands.

$ drush migrate-upgrade --legacy-db-key migrate --legacy-root=/var/www/my_project --configure-only

This creates the migrate files in your config/sync directory

Next, perform the actual migration

$ drush migrate-upgrade --legacy-db-key migrate --legacy-root=/var/www/my_project

Roll Back and Repeat

You should now have your site content and structures migrated. You can now work on the site and finish off the views and theme work.

In the meantime, the live site may have new content - using drush we can roll back and re-import the content required.

$ drush migrate:rollback d7_node_complete:node_machine_name

Drupal 8 Upgrade

Simple! Well, maybe not simple exactly, but a good starting point for your project.

One issue that we came across was the lack of coherent documentation of the migration process and drush commands - on top of which, the system is changing and evolving over time. A lot of information is out of date. If you spot anything that's no longer current, let us know in the comments and we'll see if we can keep this up to date.

Add new comment

Request a Free Quotation

Your Name