Migrating data from Movable Type to Drupal

NOTE: This article is now out of date. Better notes on migrating from Movable Type to Drupal are documented on Drupal.org.

Why migrate

I migrated my MT blog to Drupal. It wasn't easy to make this decision, because I became used to the ease of use that came with MT in terms of setting up, administering, and blogging. I simply found that MT was lacking in some of the features and scalability I need, particularly with regard to classification and news feed aggregation. Since I've been using Drupal for the past year and extolling its features, I decided to eat my own dog food and use Drupal for my personal site. This way I can contribute to its development because I'll be looking at it more from the back side.

Migrating was not exactly for the PHP/MySQL novice -- which I consider myself -- so I wanted to document my experience for others who might consider the same move. I encourage anyone who decides to go with Drupal to please consider becoming part of the development list and get involved with helping evolve the application. Drupal is very developer/programmer-centered application at the moment, catered to technical people, but if non-technical people or people who demmand ease of use and uasbility begin to add their voice to the development list or to the Drupal web site forum, perhaps the administration experience will improve. I hope to throw some time into making these types of contributions in the future.

So here's how I migrated (this is being updated presently):

Methodology

Overview

  1. Prepared IA for site in order to move all static and MT content into Drupal CMS. Will explain this further as I get time.

  2. Prepare index templates in MT to dump blog records as complete MySQL INSERT statements for Drupal's node table.
  3. Prepare index templates in MT to dump categories as complete MySQL INSERT statements for Drupal's term_node table. (Follow-up: I decided to forego this step and re-index everything as I changed my taxonomy. I also had some difficulty with removing index terms. Will explain this later.)
  4. Create RedirectRules in .htaccess to forward browsers going to old MT URLs so they will see new Drupal URLs
  5. Pending: Import old comments and insert as anonymous. Not sure if I want to do this yet.
  6. Pending: Create "story" pages for all static content I had in Papers, Projects and Portfolio sections.
  7. Pending: Think about how to migrate links from Gossamer Threads into weblink module. Not sure this is worth doing because of the categorization mapping. May just clean these out and enter by hand, which might be a hassle because there are a lot of records.

1. Information Architecture

My strategy regarding organization of site content was to use Drupal's taxonomy features to separate content along different attributes. I imposed a section/category structure that will inform global navigation. These are general rubrics that describe types of content. I then used these rubrics as terms in a taxonomy/controlled vocabulary named "Category".

Category terms:

  • Weblog
  • Papers
  • Projects
  • Portfolio

These Category attributes are used to make up the global navigation. I made links in the global navigation point to those pages which match terms from that taxonomy. For example, the Weblog term has an id of "4", so the URL for that global navigation link is: index.php?or=4.

I then wanted an additional attribute for describing content, regardless of where they fit into the categories. So I created a new taxonomy/controlled vocabulary called Subject. I apply terms from the Subject taxonomy to content so that one can browse/find related content. I display the entire subject taxonomy on the home page and display subject headings attributed to each content node.

2. MT Index template to create MySQL import file for Drupal.

I basically created an MT template that is saved as php file -- just named it dump.php. After it gets rebuilt, I viewed the source of the file in IE and then saved it on my server. Then I loaded the file into MySQL using:

mysql -h[host address] -u [user name] -p[password] [database name]

3. Category dump

I decided not to actually use this because I changed my categories significantly in the Drupal system, but here's how I set up the category dump MT index template.

Map the MT category labels to the new Drupal category IDs and assign variables. Save and rebuild the MT index template. View the source on the built file and load into MySQL.

<MTEntries author="jibbajabba" sort_order="ascend">
<?php
$cat = '<$MTEntryCategory$>';
if ($cat=='Subject » Parenting'){$drupalcat='3';}
if ($cat=='Subject » Silliness'){$drupalcat='38';}
if ($cat=='Subject » Site development'){$drupalcat='2';}
if ($cat=='Subject » Scripting'){$drupalcat='37';}
if ($cat=='Subject » Design'){$drupalcat='36';}
if ($cat=='Subject » Art'){$drupalcat='42';}
if ($cat=='Subject » Information architecture'){$drupalcat='1';}
if ($cat=='Subject » Musings'){$drupalcat='43';}
if ($cat=='Subject » Notes to self'){$drupalcat='43';}
if ($cat=='Subject » Politics'){$drupalcat='41';}
?>
INSERT INTO term_node (nid, tid) VALUES (<$MTEntryID$>, <? echo $drupalcat ?>);
</MTEntries>

4. .htaccess in old directory with RewriteRules

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^weblog/archives/000(.*).php /drupal/node.php?id=$1 [R]
</IfModule>

Comments

01 hruodland@drupal.org
11/05/03 @ 17:53

Hello!

I'm having trouble understanding your account of how to do the migrations, except in very general terms. Some issues:

  1. Do you have a copy of the MT template that creates the MySQL import file?
  2. Your instruction on loading the import file into MySQL basically says how to start up mysql with the right user and database, but not what to do next.
  3. I didn't understand your "category dump" mt index template, so I tried using it (with modifications -- my true MT user name, the real names of my MT categories) as an MT template. The output simply reproduced the input. A bit more explanation of how to use it would help.

I should say that I have only the very slightest exposure to php and MySQL -- barely enough to get scripts to work and to get a db started and connected to an application. With 1246 reads on this page though there may be others who aspire to something more flexible than Moveabletype and could also use some help.

Thanks for any enlightenment!

02 jibbajabba
12/26/03 @ 12:54

Keep in mind that these notes are a year old, so this migration was to Drupal 4.0 (I think). I'm sure someone must have come up with a better way to do MT migration. At the time, this was the only way I could figure out how to do it because no one had done it yet and documented. I'm not going to be able to help out much more on this because I haven't migrated with the current version of Drupal.

Responses to your specific questions below:

You ask > Do you have a copy of the MT template that creates the MySQL import file?
Your instruction on loading the import file into MySQL basically says how to start

I respond > Your view of some of the template got mangled somehow when I upgraded recently. Filter changes perhaps? The template with MySQL INSERT statements should appear on the page now.

You ask > Your instruction on loading the import file into MySQL basically says how to start up mysql with the right user and database, but not what to do next.

I respond > I assume here that you know how to use MySQL. You simply save the file of MySQL INCLUDES generated by the Movable Type template then load the data into your Drupal database using:

mysql -u nobody -p drupal < [path to the MySQL file]

You asked > I didn't understand your "category dump" mt index template, so I tried using it (with modifications -- my true MT user name, the real names of my MT categories) as an MT template. The output simply reproduced the input. A bit more explanation of how to use it would help.

I respond > Each category is a unique ID number in the Drupal taxonomy term_data table. At the time I wrote this page, the term table was called something different, though. The point is, you have to create your taxonomy terms in Drupal, get the tid for each term, then map your MT term labels to term tid in Drupal.

Advertisement
03 jibbajabba
12/26/03 @ 12:55

Keep in mind that these notes are a year old, so this migration was to Drupal 4.0 (I think). I'm sure someone must have come up with a better way to do MT migration. At the time, this was the only way I could figure out how to do it because no one had done it yet and documented. I'm not going to be able to help out much more on this because I haven't migrated with the current version of Drupal.

Responses to your specific questions below:

You ask > Do you have a copy of the MT template that creates the MySQL import file?
Your instruction on loading the import file into MySQL basically says how to start

I respond > Your view of some of the template got mangled somehow when I upgraded recently. Filter changes perhaps? The template with MySQL INSERT statements should appear on the page now.

You ask > Your instruction on loading the import file into MySQL basically says how to start up mysql with the right user and database, but not what to do next.

I respond > I assume here that you know how to use MySQL. You simply save the file of MySQL INCLUDES generated by the Movable Type template then load the data into your Drupal database using:

mysql -u nobody -p drupal < [path to the MySQL file]

You asked > I didn't understand your "category dump" mt index template, so I tried using it (with modifications -- my true MT user name, the real names of my MT categories) as an MT template. The output simply reproduced the input. A bit more explanation of how to use it would help.

I respond > Each category is a unique ID number in the Drupal taxonomy term_data table. At the time I wrote this page, the term table was called something different, though. The point is, you have to create your taxonomy terms in Drupal, get the tid for each term, then map your MT term labels to term tid in Drupal.

04 Anonymous
02/01/04 @ 20:47

TrackBack from KnowProSE:

urlgreyhot : Migrating data from Movable Type to Drupal Maybe I should be eating my own dogfood as well. This site moving to Drupal makes so much sense now that I'm facilitating students work and so on. Hmm. Maybe some...

05 Drupal Japan (trackback)
11/24/04 @ 09:57

I [ax: jibbajabbaboy] 've chronicled my experience migrating a MovableType site to Drupal.. The process was fairly simple, but required a

06 Anonymous
10/26/07 @ 00:31

Heres a wrap up on the recent upgrade to the import typepad (MT) module by myself.

hope it helps!!!

07 Berita Harian
02/03/08 @ 10:52

bro, thanks for the post..this post really helps me to understand it more..i hope more great post is coming..;)

08 Build a bear
05/16/08 @ 06:44

i'm gonna second that..it is hard to find such references but when i got here, i instantly understand the whole big picture and how it works...thanks ;)