Jun 04

BlogCFC2WPlogo1.gifI looked around for a migration script to port my blog from BlogCFC over to WordPress and didn’t find anything so I wrote one. First lemme say that BlogCFC is a great piece of software and I don’t want to encourage anyone to move away from it. For myself the decision to move to WP was one of those “eat your own dogfood” choices. 100% of the stuff we’re building at Grid7 right now is centered around Structured Blogging and Microcontent. WordPress and Moveable Type are currently the only two authoring tools that have plugins that support this. For me to advocate microcontent without having the ability to publish it would be like Ray advocating BlogCFC and hosting his own blog on WordPress. Plus removing barriers to exit on a piece of software should theoretically increase the adoption of its usage because people can now safely use it knowing that they aren’t locked in permanently. Anyways, I asked Ray if he was cool with me releasing this code and he had no problem with it. There is a Readme included but basically here’s what you do:

Download the BlogCFC2Wordpress.zip file

  1. Setup a new instance of WordPress (you’ll need to be able to run CF and PHP side by side)
  2. Configure a datasource in CF administrator for your new WordPress db.
  3. Extract the contents of the zip file to a directory on your site
  4. Modify the config.ini file to reflect the source and target datasources
  5. Provided you want a fresh install you should clear out the dummy data that comes with WP
  6. Run the RunMe.cfm file
  7. Delete the BlogCFC2Wordpress directory
  8. Two optional last steps
    1. put the rss.cfm file in the root of your wordpress blog to keep all your old subscribers
    2. put the index.cfm and qBlogCFCPosts.xml files in your root to handle redirects for all your old links

Provided that it worked you should see a screen that looks like this->

BlogCFC2WPscreenshot1.gif

Obviously you’ll need to mimic the directory structure of your BlogCFC instance so all the files referenced in your posts continue to work. I just moved my downloads and images directories over and it worked fine. I updated the stylesheet to include the .code classes so inline code would display properly. There were some weird idiosyncracies with the way that the inline embedded flash player was handled by WordPress/php but that was really the only gotcha and I just referenced it in a new window on entries where it broke (it was something to do with the tag). If you do the last two steps your users should never have to change anything and all your legacy links should continue to work.

The code is actually commented (i know, crazy right?) and makes heavy use of components so it may have some instructional value. There’s some other nuggets in there and one technique in particular that I’ve started doing (and I don’t know whether this equates to CFUnit or another type of unit testing – i’m admittedly horrible about not writing unit tests) but it’s been a time-saver on another project where I’m dealing with a long sequence of calling various components that access external systems to get the objects I need to do an operation. Basically it’s a few lines of code that lets you serialize the object and write it to a file so that for testing rather than calling the components each time, you can instead read the file and deserialize it to create the same object so it behaves as if it were getting it from the prior sequence. This may be old hat for others but it’s a technique that has saved me time and the pain of repeatedly clearing out database entries.

The performance of the migration script is fine for me (it took 13secs to move 73 posts, 75 comments, 130 category mappings and 18 categories). It’s admittedly not optimized (I prefer the syntax and I realize it instantiates the component on each request under this method). There’s plenty of room for improving this with the function-style syntax for instantiating objects and for someone like Ray who has 5000+ posts you might have to (or else bump your Timeout in the CFadmin) but it worked fine for me and I have no desire to do this. I’ve tested it against CFMX7, MySQL 4.1 and Win2k3 with BlogCFC v. 3.8 to WP v.2. There are some new fields in the latest version of BlogCFC so you would need to make a few minor modifications to the query syntax but it should be pretty painless. Also the sql is vanilla with no stored procs (all the logic is in the cfc’s) so it should also work with other databases like Postgres or MSSQL and it should run fine on BlueDragon. It should be noted that I did end up using a queryToArray utility found here and this is embedded in a util component in the distribution.

The usual discalimer applies on this code – backup your WP db before you use it if there’s anything that is worth saving! I’m not providing support on the code. You can repost it and take it apart and make it better if you want but please leave the original comments and license intact. It’s the MIT license which is as close to having no license as you can get.

One thing – I was on the fence about using feedburner because athough I wanted the stats and the other promotional and convenience features they offer, I didn’t like the idea of promoting an RSS link I don’t have control over (ie. they decide to start charging and have you hostage by having control over your feed). My partner came up with the great idea to use a link that redirects to feedburner. Simple and genius.

Big ups to Ray Camden and Matt Mullenweg for writing useful Blog authoring tools. Hopefully this migration utility makes both products more accessible to others.

Oh, and in the never-ending pursuit to master the art of the tripodless qtvr, I took one yesterday in the middle of the pool at this pool party we went to on the side of Camelback Mountain. It was like the house they blew up in Lethal Weapon 2 and it was was every bit as ridiculous as it looks.

altitudePoolPartyQTVR1.jpg

23 Responses to “Utility to migrate your blog from BlogCFC to WordPress”

  1. FilSchiesty says:

    Good to see you on WordPress now.

    Keep up the good work.

  2. sean says:

    fyi: i just fixed a minor bug in the legacy redirects index.cfm file. i made the URL comparison case-insensitive and it should work on all of them now regardless of case.

    sean

  3. Shanti says:

    Dude – crazy party!

    I was expecting it to be a video but that 360 degree pic was sweet.

  4. Jared Smith says:

    Sweet tool! There were a couple of bugs in it though. There were a couple fields that in the default WordPress DB could not be null, so I just added some empty text to them or set the wordpress db to allow nulls so the queries would update. They are category_description in wp_categories and post_excerpt, to_ping, pinged, and post_content_filtered in wp_posts.

    Then I realizd that the morebody field is not appended to body – so if you have posts that are split, only the first part gets moved to WP. I fixed this so body and morebody were joined with in the middle and got all the categories and posts to insert in the WP db.

    I got that far, now CF is throwing a “Query Of Queries runtime error. Unrecognized java type” at WordPress.cfc line 63. I think it has to do with buggy datatypes – http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/using_r6.htm
    I tried to fix this, but couldn’t come up with something that worked. I’m pretty sure the fields just need to be set to text instead of… whatever it’s doing with them. No biggie, I just redid my post categories in WordPress and I’m set.

    Anyways, it could use a little work, but with just some minor modifications it did most everything I needed.

  5. sean says:

    Jared,
    thanks. What version of BlogCFC did you migrate from? New blog looks nice. I had no problems migrating mine from v. 3.8 and I noticed there were a bunch of new fields in the latest version of BlogCFC so I’m sure at various versions between there are discrepancies such as you mention. Glad you found it helpful though.

    Sean

  6. [...] Wouldn’t you know that as soon as I convert my blog over to BlogCFC from WordPress that someone goes and builds a utility to do the exact opposite! [...]

  7. Magic says:

    Lol I love the ONE GUY (slightly right of 360 shot when it uploads) who is wearing jeans and a belt. Way to prepare for a pool party.

  8. [...] A quick search on Google turned up this post by Sean Tierney, but his migration script doesn’t work for the newer versions of WordPress. I attempted to muck around with the queries, but quickly grew tired of it. [...]

  9. [...] There were a couple resources that were instrumental in my being able to make the jump. The first was Sean Tierney’s blog where he posted a set of file to help move my blog from BlogCFC to wordpress. I was able to use Seans script to move me to a WordPress 1.5 site with only a couple modifications. Then upgrading to the latest WordPress was a matter of unzipping the new files, copying over my config and running an upgrade script. After that I needed to move my Typo blog over as well. I found several resources on moving from Movable Type to Typo, so I chose to use one of those as an example to write a script that outputs they Typo blog data into the MT data format. This is easily consumable by most blog importers including WordPress. I will attach the MTOut script to this post. Just drop it in your Typo scripts folder and give it a run. By default it will just output the code to the STDOUT, but if you use the -f flag you can specify the filename you would like to write the data into. Of course there is always the -h to see the options. [...]

  10. [...] I have completed my move to wordpress. I completed the move of my blog last night with the help of Sean’s little utility, blogcfc2wordpress. I had to install wamp on my windows coldfusion box, I also had to download an old version of wordpress (2.1) as somewhere along the lines the database names were changed and blogcfc2wordpress has not been updated. I then downloaded WordPress Export, exported my data and imported it into my new blog. I fixed the post that I used blogcfc’s more and code tags on. All in all a pretty easy migration with a little data massage. Bookmarks: March 4th, 2009 in Personal | tags: BlogCFC, blogcfc2wordpress, Coldfusion, wamp, WordPress [...]

  11. iddaa says:

    Dude – crazy party!

    I was expecting it to be a video but that 360 degree pic was sweet.

  12. ssk says:

    just fixed a minor bug in the legacy redirects index.cfm file. i made the URL comparison case-insensitive and it should work on all of them now regardless of case

  13. thanks for contribution.

  14. I just redid my post categories in WordPress and I’m set.

  15. FilSchiesty says:

    Good to see you on WordPress now.

    Keep up the good work.

  16. There is a big difference between scope creep and scope change. Creep can’t happen if the business users have signed off on the requirements.

  17. [...] This post was mentioned on Twitter by Sean Tierney. Sean Tierney said: thinking about making a Ning->Buddypress exodus script. did 1 way back for diff system: http://bit.ly/bzI7Gm NE1 have a free Ning test acct? [...]

  18. epilasona says:

    There’s already a couple of migration tools written by some ColdFusion folks.

  19. zayıflama says:

    I am going through the same thing. How did you migrate your blog entries from blogCFC to WordPress? I have had some issues, having only a handful transfer with the RSS import utility (using blobCfc's ability to export to RSS).

Leave a Reply

preload preload preload