How I move a WordPress blog to a new host

Aaron Brazell described how he moves his WordPress blog to a new host and it’s very familiar since I’ve done something similar a few times over the last few months.

I’ve figured out a few things from those moves which you might find useful if you get sick and tired of your hosting:

  1. If you’re self hosted and have a domain name, set the “time to live” (TTL) to as small as possible, say 15 minutes. You should do this about 24 hours previously. Doing this will mean that visitors to your bog will start seeing your new host sooner!
  2. Just after you dump your database to a file for export close all your posts to comments. I do this with the SQL, UPDATE wp_posts SET comment_status='closed'. Now quickly transfer your db over and get your site up and running in the usual manner. Your old site will still get traffic for a while yet. Googlebot will still visit too, but nobody will leave comments there so you don’t have to worry about synchronising your comments table. You could do the same with ping_status too if you get a lot of pings.
  3. For extra brownie points add a small message in the comment area informing the visitor that, “Comments are disabled. This site has moved to new hosting. Please check back later to leave a comment.”
  4. If you fiddle with your hosts file make sure there isn’t an entry for your domain pointing at the old site. That happened to me on my Macbook and even after updating /etc/hosts it still didn’t work right. I had to reboot the laptop!
  5. Say “Thank You” to anyone who helps, especially support staff!

Good luck moving, it’s not as hard or as daunting as it might be. ssh, scp/rsync, mysql/mysqldump and tar/gzip are your friends when moving!

Further Reading:

PS. Thanks to Linode for hosting, Blacknight and Michele for DNS, and you for WordPress.


You might also like

If you like this post then please subscribe to my full RSS feed. You can also click here to subscribe by email. There are also my fabulous photos to explore too!

Published by

Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

46 thoughts on “How I move a WordPress blog to a new host”


  1. Grannymar – just get George to move your blog if you ever want to, that’s what son-in-laws are for! :)

    We realised yesterday that it was possibly the last or second last Sunday where we could sit at the breakfast table and read the Sunday Times in peace and quiet, for a long time! Jacinta is well, she gets tired easily but the sun over the weekend was great! She’s glad she wasn’t pregnant over a hot summer though. Not that fond of high temperatures.

    Here’s hoping the next trip to the hospital will be less stressful!


  2. Thanks for the link, Donncha!

    As for this:

    If you fiddle with your hosts file make sure there isn’t an entry for your domain pointing at the old site. That happened to me on my Macbook and even after updating /etc/hosts it still didn’t work right. I had to reboot the laptop!

    1. You were probably using Firefox which is notorious for keeping cache stuff. Do yourself a favor when its important to get the latest and greatest and use Safari. :)

    2. Run lookupd -flushcache everytime you save /etc/hosts…

    :)


  3. You’re welcome Aaron! Even worse than Firefox, I’m using Flock. It held on to the old IP address for at least 24 hours.

    I even wondered why my post from Flickr hadn’t shown on inphotos.org yet. It had been posted, but on the new host :)


  4. Hi Donncha,

    DO you’ve any solution for importing WordPress MU SQL table into WordPress 2.1.3?

    Advice.

    DG…


  5. DG – Just like on WordPress.com you can use the export tool and then import it back into your new WordPress install.
    If you don’t want to do that then simply dumping the tables to a file and copying the posts, comments and related tables into your new wordpress install should work ok. Just don’t forget to change user IDs in the posts table!


  6. This is going to be a really newbie question – how do you tell if your site is getting lots of pings? :)

    Thanks for the guide though!


  7. Mosey – See the pingbacks below your comment on this page? Those are pingbacks. They happen whenever a blog that supports pings or trackbacks (like WordPress, or Typepad and many other blog engines, *not* Blogger or most photoblog software AFAIR) mentions another post. The blog sends a “ping” to tell the other post, “I mentioned you! Add this to your comments please!”

    It’s a great way of keeping a conversation going, especially across separate websites. Check the two pings below for posts about moving your blog!


  8. Hi Donncha, Thanks for the detailed (et. plain English :D) explanation – I found it very helpful! Alas my site doesnt seem to have many pings so hopefully more people will link soon.


  9. Thanks for this howto, I’m planning to move in a few days.
    Just a question: that MySQL query closes all comments for old post, but what about to reopen them after migration?
    And more important: what about if I have some old posts with pen comments and other with closed comments and I’d like to maintain the same configuration after migration?
    TIA.


  10. fmf – you’re welcome! You should dump your database to disk before closing off all the comments. I presume your site isn’t that busy that you’d get a comment or two in the few seconds it would take to switch apps to phpmyadmin :)

    This also avoids the problem of remembering which posts were open before!


  11. “I presume your site isn’t that busy that you’d get a comment or two in the few seconds it would take to switch apps to phpmyadmin”

    Of course that wasn’t the issue: I only have 456 posts and 499 comments, little more than one comment per post.
    I just miss the ‘dump your database to disk’ meaning…
    My fault.
    Thanks, maybe in the near future if I’ll change my hosting and I’ll translate your howto for italian speakers in my blog I’ll give you credits.


  12. Hey Donncha,

    Great post – I only wish I found this sooner :-)

    I set up my own self hosted blog but started from scratch as I didn’t know how to transfer the old one and get it to work.

    I’ll definitely use this if I ever have to transfer them in the future.

    Thanks again!

    Rich


  13. I think I’ve read something simillar a few days ago. I don’t remember where, might have been on digg.com or slashdot.


  14. Before moving to new host you should read the feedback of existing users. If you plan on having a lot of hits you should consider hosting provider with load balancing and redundancy, not just a single-host based solution.


  15. Just a short note to say thank you for the information. I recently faced this issue on one of my older sites and moving things around was certainly made easier by using the info provided.


  16. Hi
    Why wouldn’t you just take a home directory backup from your cpanel backup area. This will create a .tar.gz file that includes all your files, email, database entries..
    ftp the file to your new account at the new host and ask support to install it.
    I do this all the time and it works the best for wordpress and other non wordpress sites as well.
    The only catch here is make sure your user id in the new site is the same as the old userid ( the one stored in the backup )
    Please, let me know if you have any questions.
    Sherif


  17. Hm, I’m planning to move about 20 blogs to another host. Do you think it is possible to automize the process? Are there any tools for that?


  18. Some interesting comments there. It all sounds very technical, I can manage to create SQL databases, etc, but I have never moved one. I have bookmarked this page, thank you.


  19. or if it could be possible for the blogger to do a 310 redirect to their new domain blog from the older wordpress site maybe thats then less work to redue some things or lose some posts.


  20. Hello there,

    The best thing that you should is use your php admin and then to backup all you site content use the feature export and then you can an option somewhere just choose complete insert and at bottom part you can choose a compression to use it up to you on what compression that you are going to use and go click after that it ask you where to save your backup well choose a safe place where you can put your backup. and lastly bak up all your wordpress file by using your ftp account and download all your file to your computer. after finish that thing you are now ready to transfer to a new host for your blog. Again use your php admin of your new host and import your backup database to new host and click go after that your database is ready. and then follow with your files by using the ftp account of your new host upload all your files to your new host and then run as normal.

    Revero
    Make Money With Blogs


  21. When you move your blog to a new host should you worry about old content not being able to be retrieved? Should 301 redirects be configured so if any content that does have trouble being found you can direct the traffic back to the proper content?


  22. Great resource, thanks. I think I will have to start looking at a new host very soon, and the wonderful resources out there (such as yours) should certainly mean that things will go smoothly. The further reading you’ve provided seems excellent too, so thank you. I found that changing the TTL settings was a very interesting point; I will definitely be employing that one and seeing the benefits I’m sure.


  23. Moving from one host to another is always fun, not really but in a manner. You do learn about the process and after you do it a few times it becomes like second nature.

    It can be much easier if you choose a new host that uses the same type of hosting control panel. And if you have cpanel you can make the change super fast and easy. Most cpanel hosts will even do it for you if both the old and new has cpanel.


  24. To flush your DNS cache:

    Mac 10.4: lookupd -flushcache
    Mac 10.5: dscacheutil -flushcache

    Windows: ipconfig /flushdns


  25. There’s a wordpress plugin that automatically makes backup of your database regularly and send it to a mail box. You can set up the mail box you’d like and the period of time between backups. Helps when moving.


  26. Why wouldn’t you just take a home directory backup from your cpanel backup area. This will create a .tar.gz file that includes all your files, email, database entries..
    ftp the file to your new account at the new host and ask support to install it.
    I do this all the time and it works the best for wordpress and other non wordpress sites as well.


  27. It’s very easy really, and there is alot of good people and good posts with the right info, The trouble is my FTP (CoffeeCup Direct) is playing up and missing files and corrupting images that it driving me MAD.

  28. Pingback: Moving WordPress

Leave a Reply