Moving WordPress – My Story!

October 24, 2011 | By Rakhitha | Filed in: Me, Myself & I, Tech.

Well! this topic is well covered here, and probably repeated all over the web. But I am going to write this post any way. Because my WordPress move went quite well. And here is how it was done.

Everything Starts with Taking a Backup

A move is as simple as a backup and restore. You back up your old host and restore it at your new host. That is all you got to do if your domain name/blog URL is not going to change. Backing up has two steps. You need to back up your database and you also need to back up your files. You don’t need t back up entire home directory or public_html folder. If you have wp-content folder backed up that’s good enough. Because that’s where all your Thames, plugins and uploaded files are stored. If you have access to cpannel this is a very simple task. Otherwise you may need to use one of those plugins which allow you to back up the database  and files.

Restoring at New Host

When I was moving, I did not want to have entire public_html copied from my old host to new host. Instead I wanted to have a relatively clean setup. Therefore I decided to install a fresh copy of WordPress at the new host. And then copied wp-content of old host in to new host. This worked for me because at my old host, I had an up-to-date WordPress installation. There were no major version mismatches. If you are restoring from an old backup, may be you will need the entire public_html to be restored.

Next step is restoring the database. If you using cpannel, this is as simple as uploading the backup in correct cpannel page. Otherwise you will need to extract the database backup, which will give you a sql file, and run it on your new database host.

After restoring the database at the new host, You need to edit wp-config.php file to point to restored database. There is one more thing you need to do in order make your WordPress work after this change. That is you need to grant your my sql user (one you have in wp-config.php file) the access to newly restored database. This can easily be done on cpannel MySQL databases page.

As long as your blog URL remain same this is all you need to do. We’ll come to URL change later.

Pointing the Domain to New Host

This is the tricky part. You need to change the NS records of your domain to point to the name servers of your new host. But this change take some time to take effect. Because name servers all over the world have cached your DNS info. In next 48 hours, some will still connect to your old host using old cached DNS information. Some might still connect to your old name server at the old host to find your IP. To minimise the confusion, make sure to update the DNS records at your old host to point to your new host IP address. You can do this by using DNS Zone Editor on cPannel, the advance one.

But regardless of what you do in next 48 hours, when you visit your site to do any cleanups, you can’t be sure which version of the site you are looking at. To sort this out, it’s best to add a new post or make a visible change on your blog at the old host. You have to do this after taking backups, otherwise same change will come to new host through the backup.

Make sure you have both sites up at both locations for next few days until all the caches start pointing to new place.

Prevent Your old Site Going Zombie

You may also want to disable any plugins at your old host. Specially the once that are responsible for dealing with search engines and others services such as Twitter/Facebook. Otherwise it will keep feeding details of a dead (undead to be exact) site to google and other places. This will have to be done before you change the DNS settings.

Dealing With URL Change

Well, if your URL going to change as a result of the move, your site at new host will not work after the move. To fix this you need to change two WordPress options in the database.  One way to do this is to log in to PhpMyAdmin, query ‘_options’ table, and look for options ‘siteurl’ and ‘home’. Both of them need should change to your new URL in order for your blog to work.

Or you can edit wp-login.php file and add following two PHP code to make the change. But make sure to change them back once it did its job.

update_option('siteurl', 'http://your_new_site_url' );
update_option('home', 'http://your_new_site_url' );

In my case I didn’t have to do this permanently as it was the same URL. But if you have an alternative URL for your new site, which you can use until your domain change take effect, you can have this changed temporary. But make sure to have your search engine related plugins disabled. Because you don’t want your unborn site pushing its temporary address to search engines, social networks and what not.

Never Forget to Plan

Even though this information is available all over the place, don’t ever make the mistake of failing to plan. Check to see if you have any changes done manually in your old host. Read the moving instructions on wordpress codex. Check what are the things you need to move to cover all the changes. Test the restore process in your local host in case you haven’t ‘restore-tested’ your backups already.

Finally the disclaimer :), I may have not included all aspects of moving, as this post is simply about my moving experience. If you want a smooth transfer don’t consider this post as a short cut. One more thing, if you are an expert in the moving industry, and find that I have done something wrong while moving this site, please let me know so I can fix it before it’s too late :).

Happy Moving!


Tags: , , , , , , , , , , , , , ,