Swing Migrations: Drupal to WordPress

I use a lot of tools when I migrate sites, and one of them that I’ve used a few times before is a WordPress importer that takes your Drupal database and migrates it into a WordPress format. It’s available here, and I’ve mentioned it a few times before – does a great job, although only a partial job (it doesn’t import images into the database and attach them, but there are other tools to do that part of it, including some I’ve written).

So this particular tool, unbeknownst to me, actually nukes your entire WordPress database before it imports the Drupal content. I’ve only ever used it on new sites before, so I didn’t think anything of it – I set it up as usual, connected it to both databases, ran the import script and …

Screen Shot 2016-07-29 at 10.24.25 AM

I found out that everything was gone. This is a site we’ve been working on for about 12 months on and off, waiting on designers, content, videos, new logos, etc – it has been a long time coming. Anyways, no big deal, I just went looking for my backup – and couldn’t find it.

It’s the best. I wanted to both throw up and lie down and cry at the same time.

Turns out I was just looking in the wrong folder, and had it restored in another 5 minutes, but it brings me to my next point – if you’re going to import data into an active site, do a swing migration. It’s simple, can be done in a few steps, and is no big deal.

Step 1.

Set up a new database, then import the contents of the existing WordPress database. In this case, I just called it temp, and gave the Drupal user access to it in preparation for the migration.

Step 2.

Perform the migration using the temp database instead of the live one.

Screen Shot 2016-07-29 at 10.30.04 AM

Step 3.

Switch the wp-config login details over to the temporary database. Make sure you save the original database login details first, comment them out or copy them to another file. The temp database should have most of the original WordPress database, so login details will be the same, everything will work, just no content will be available. Once you’re logged in, go to Tools, Export, and pick your content type and date range. For this usage case, I picked everything in the past 12 months, which was after the original database import was performed. It will save it as an XML file which you can use to import.

Step 4.

Change the wp-config login details back to the original database login details, log in, and again go to Tools, but this time go to import. Click on WordPress at the bottom, install the import plugin, and run it.

Screen Shot 2016-07-29 at 10.35.54 AM

Choose the XML file you just saved, import it, and let it run its course. You may have to change some settings if the authors don’t match, and you may run across some post duplication, but it will import everything you need.

Step 5.

Clean up the import – Drupal has some annoying quirks to it with the default settings, like using nodes and permalinks only containing numbers. Some of the tools I use to clean this up include generating post slugs to match the title, then migrating the images from these same posts (both plugins that I have written as tools to migrate Drupal to WordPress). Really, some of these steps need to be done on the temporary database before you transfer the posts to the live database, but at least you get the general picture. You’re all set at this point to continue working on your live site.

Leave a Reply

Your email address will not be published. Required fields are marked *