Back In The Saddle: A Tale of WordPress Migration

I have been away from technology blogging for a few years and I have missed digging deep enough into topics to actually put reasonably coherent thoughts together about them.  Many things have changed in technology since I last published.  There are many topics to catch up on and I look forward to jumping back into the fire.

Today’s update covers what it took for me to convert from five year old version (3.4.1) of a self-hosted WordPress blog to an updated shared hosting version.  I did a bit of searching and found bits and pieces of what would be needed to accomplish this task. There were a few technical hurdles to cross, so I thought I would share the process that I followed. Perhaps it will save someone else some time if they ever try to do this.

After much personal debate, I selected DreamHost as my new provider and created my account earlier today.  It has taken me about six hours to get everything migrated and working correctly. Frankly, it went better than I had expected.

My local host had been physically “off” and collecting dust for the last three years or so. After standing that machine back up I had to adjust web server settings to even bring up the old blog.  I then had to export my existing content.

Exporting WordPress Content

WordPress Export Operation

The export process produces an XML file which represents all of the content from the existing site. Technically, this operation produces a WordPress eXtended RSS (WXR) file.

After completing the basic setup of my new WordPress configuration, I then imported this XML file into my new environment.

Importing the WXR data into the new WordPress instance

Unfortunately, this export/import operation doesn’t include media files.  The basic structure and posts are present after the import, but no media files had yet been transferred.  The import function in the new instance does have an option for importing attachments.  I was unable to even test using this method since the old instance was not actually available any longer on a live site.  If it had been available, I would have tried this method first before charging on with the steps below.

Since I wanted to have a full backup from the old web server configuration anyway, I made a complete copy of the web site structure using tar from my old Mac Snow Leopard server.

hoppy:~ rick$ cd /Volumes/ServerHD/UserData
hoppy:UserData rick$ ls Library
WebServer      WebServer2
hoppy:UserData rick$ tar cfv /tmp/Library.tar Library
a Library
a Library/WebServer
...

Getting the media migrated correctly is tricky business. If you would merely import all of the media files again, you would have to update each and every post about where the media files reside.  I knew there had to be a better way.  Fortunately, I found a plugin to help called Add-From-Server. This plugin allows you to import media files in bulk into the new WordPress instance in the same location they came from. Media files are usually stored within WordPress by the date they were added to the Media Library.

Max:helpmeusetech rick$ find wp-content/uploads -type d -print
wp-content/uploads
wp-content/uploads/2011
wp-content/uploads/2011/02
wp-content/uploads/2011/03
wp-content/uploads/2011/04
wp-content/uploads/2011/05
wp-content/uploads/2011/06
wp-content/uploads/2011/07
wp-content/uploads/2011/08
wp-content/uploads/2011/09
wp-content/uploads/2011/10
wp-content/uploads/2011/11
wp-content/uploads/2011/12
wp-content/uploads/2012
wp-content/uploads/2012/01
wp-content/uploads/2012/02
wp-content/uploads/2012/03
wp-content/uploads/2012/04
wp-content/uploads/2012/05
wp-content/uploads/2012/07
Max:helpmeusetech rick$  

To import the media files, I recreated the directory structure shown above in the new instance’s uploads directory. I then unpacked a copy of the old uploads directory on my local server.  For each of the existing upload directories, I ran Add-From-Server and imported my media files.

Once completed for each of the uploads subdirectories, the new instance of the WordPress site is operational.

A huge shoutout goes to Stephanie at DreamHost technical support.  She guided me through a site lockout issue today which had left me dead in the water.  More on that issue in my next post.

This entry was posted in 3 Geek, WordPress and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *