I spent a bit of time over the Xmas holidays 2015 migrating this blog from its original home to a new hosted WordPress site.
This blog has a long and chequered history – I began posting back in 2003 when I had the blog hosted on a system called MoveableType. Somewhere in 2007, I wrote some code that moved the content across to CommunityServer which I ran on a hosted server and it stayed there until late 2015.
During that time CommunityServer had pretty much died but I was a bit stuck with it in that I’d got a couple of thousand posts in its database and there never seemed to be a great utility for exporting content and so, like a lot of old-but-useful software, I got a little bit stuck.
In late 2015, I decided that it was time to bite the bullet and move on and so I decided that I would move the content elsewhere that didn’t involve me directly managing a server.
I settled on (hosted) WordPress.
Moving my materials out of CommunityServer wasn’t completely painless and it took me around 4-5 days of effort of going around the loop trying to write code and SQL to analyse the content that I had in CommunityServer and make sure that it would land ‘reasonably’ on WordPress.
What that largely involved was;
- Taking all the content from my hosted web server like downloads, images, videos, etc. and moving it across to an Azure web server, largely preserving the folder structure to make it easier for my code to rewrite hyperlinks.
- Getting a local copy of my CommunityServer database and writing custom code in order to attempt to;
- Rewrite hyperlinks that were pointing at the old locations for images, downloads, videos, etc.
- Rewrite hyperlinks that linked from one post to another.
- Fix up posts which contained code snippets – over the years, a number of different ‘code formatters’ had crept in to my blog and patching them up after the event wasn’t so much fun
- Fix up videos – my blog site had allowed posts to contain object tags and iframes and that wasn’t appropriate for WordPress posts which (generally) have a better way of handling this.
In doing this work, I ended up writing a C# console application (!) which did old-school ADO.NET into the community server database and then I used the Html Agility Pack in order to pull apart the HTML and attempt to put it back together again with various links rewritten.
That code then uploaded posts to WordPress by using the WordSharp wrapper that I found to be a nice, convenient way of getting content posted into WordPress.
Some of that process involved digging through the WordPress REST APIs and I found that, generally, the developer docs are pretty good and the APIs seem to have the common scenarios covered and it felt good to be following in very well-trodden footsteps rather than trying to blaze a trail.
What I haven’t attempted to do as part of this migration is to preserve external hyperlinks into my blog site and so links that come into my site are likely to break. It would have been ‘nice’ to be able to do work to redirect those links but I don’t think it’s possible under a hosted model and so that’s the trade off that I’ve made.
Hopefully, WordPress can be this blog’s home for the next few years and I won’t have to write any more one-time migration code again in a hurry