March 6th, 2009

Migrating from Wordpress to Blogger

I was hosting my sister's Wordpress blog on my server, but the frequent announcements of Wordpress security problems made me really nervous. She agreed to move to Blogger, and I thought I would find a dozen migration scripts to choose from to get her stuff moved over.

Nope! I didn't find a single working automatic migration script. That might be partly because of weak Google search skills, but I think it's actually because of some of the limits Google has for updating a Blogger blog non-interactively, i.e. from a program. After you post 30-40 entries, further requests are rejected and you have to go through a Google captcha to keep posting.

I poked around for other options. Blogger has a backup/restore system that produces and consumes an XML file, but I couldn't trick it into restoring from an augmented backup file.

I eventually used a modified version of a Wordpress exporter to produce a single XML dump of all the old entries, then created individual XML files of each entry. Once a day, I post as many files to Blogger as I can before it starts rejecting requests. Since she has about 2,500 entries, I expect it to take a couple months to complete. (Comments will be lost, unfortunately.)

The migration program is a Common Lisp program. It uses a few different parts:

  • Klacks for parsing the original dump
  • CXML for rewriting it
  • Drakma for HTTP
  • grout (not yet released) for Google Data API authentication
  • firehose (not yet released) for Google Blogger API interaction

It was nice to pull much of the stuff "off the shelf" and have it just work for what I need.