Large Movabletype to WordPress migration

I was asked to move a friend’s blog from Movabletype 2.63 and I chose WordPress Since it’s a large site, there are extra issues in the migration process. Here’s how I did it.

The blog has 1200 entries, 10000 comments and 35 authors. The average post is 13 Kb and 10 Kb comments are not rare. Db is MySQL. The usual procedure for importing from MT does not work, because due to a memory limit, both exporting from MT via mt.cgi and importing to WP via import-mt.php return only a partial result or hang.

This is what I did:

  • backup the MT blog (files and database)
  • install a replica on my development server
  • install WP on my development server
  • export the MT data, import data into WP
  • backup WP
  • install WP on production server and cleanup

For backing up the MT blog, you copy all the files in the document root and the cgi scripts. Backup the database with PhpMyadmin and get a .sql file, mine was about 28 Mb.

Installing a local replica of the MT blog requires editing some configuration file and script. Setup a MySQL database with the same user and password (it’s in a cgi script). I use a standard Debian Linux machine.

On the local MT blog the export with mt.cgi works and outputs a text file. I edited the file to make sure links point to the correct location once the MT installation will be removed fro the site.

Installing WP on the local development environment is easy.

Importing into WP requires editing php.ini to increase the memory limit. I set it to 250M, then edit import-mt.php appropriatedly and import all the entries (remember to restore the original memory value when you are finished). I found an author with empty name and edited it to “anonymous” for security reasons.

Now it is time to set author passwords (default is changeme for all) and levels, install templates, plugins and do all the usual configuration on the blog. Since MT blogs used to be plagued with comment spam, I ran searches for common spam words and did a mass delete.

Once WP is ready, backup the DB. The blog is in Italian and I had an issue with the character set that was messed up when exporting via PhpMyadmin.,The following command from terminal does a dump preserving the charset and saving many headaches:

mysqldump -uuser -ppass --skip-opt --default-character-set=latin1 yourdbname >/home/user/backupname.sql

After installing WP on the production server, I had to restore the DB. The .sql file was 20 Mb. PhpMyadmin has a 2 Mb size limit for this operation, so it has to be done via a shell (I had an operator from the hosting provider do it) The command is:

# mysql -h localhost -u user -p dbname < /path/to/backupdb.sql

There are some fields in the wp-options table that must be changed to reflect the new environment. You ca do it editing the .sql file before restoring it, or afterwards with PhpMyadmin. Add the correct URL and path when needed.

Last, I setup permalinks and added this line in .htaccess to preserve at least links to the old MT monthly archives (thank you, Dan Hersam):

RewriteRule ^archives/([0-9]{4})_([0-9]{2}).html$ /index.php?year=$1&monthnum=$2

I’m still looking for a way to link to the old individual archives without preserving the old MT installation. The best I can think of is redirecting to a WP search page:

RewriteRule ^archives/([0-9]{6}).html$ /index.php?s=randomstring

When the new site was ready I had a friend proofread it. She discovered an author/post mismatch: something went wrong during the import process, and some post had the wrong author attached to it. I found it was due to the insertion of 3 odd authors in the wp_authors table, so I used PhpMyadmin to delete and assign the correct ID to the remaining authors.

That’s it! Have a look at the site, Nazione Indiana or leave a comment here if you have any suggestion.

2 commenti su “Large Movabletype to WordPress migration”

  1. Pingback: Angelsworld
  2. in the end you did a great job i always found that exporting sql backups is one thing, but returning them requires deleting every table there is. but you showed how it’s properly done

I commenti sono chiusi.