How to move WordPress site to new server with zero downtime

Update: I recommend using ManageWP to easily backup/restore/migrate your WordPress sites.

The Hunchback of Notre BresilIt often comes as a topic and I decided to write a quick tutorial on how to move your WordPress site from one host to another with zero downtime.

I will assume you are familiar with basic operations like database backup and FTP. So in order to transfer WordPress to new server you need to follow these steps:

  1. Backup the database from the old site and import it to the new site. Pay attention to database names.
  2. Change your wp-config.php in the old site to point to the database on the new site. Your old site will now run using database based on the new site and once you change the nameservers new site will have the up to date database. (You may want to check with your new hosting if they allow outside database access first. If not, you can skip this step and transfer the database at the end, when the nameserver change propagated)
  3. Backup your entire WordPress installation from the old site (this will include all your uploads, themes, plugins)
  4. Unpack your WordPress installation to the new site
  5. Change wp-config.php on the new site with new database details
  6. Change the nameservers to point to the new site
  7. That's all now you only need to wait :)

Since nameserver propagation can take up to one day, step 2 allows you to have up to date database at the moment it happens. Downside to this is slower site response in the meantime because site still runs from the old server and the database is on the new. But if you do this over the night or periods of low traffic it won't be that noticeable and you will not lose any comments or other activity on your site.

Update: You can use ManageWP to move a WordPress site with less hassle.


More like this:


Posted in: WordPress
TAGS:, , , , , , , , , , , , , , , , , , , , , , ,
Both comments and trackbacks are currently closed.

24 Comments

  1. Bob
    Mar 31st, 2009 7:19 PM

    I did all that and yet my categories and posts still point to old server. Dis I miss something? Everything else goes to new server.

  2. Mar 30th, 2009 2:22 AM

    What awesome help this would be, if I could make it work. Do you know of anything else that might keep my WP install from connecting to my new dedicated server?

    I've created and imported the database and user with full access on our new box. I edited my wp_config with the correct details including new host name. I enabled the cPanel option to allow Remote MySQL access to the new server.

    My site and forums currently reside on a 1and1 shared hosting account. The old/current database resides on some 1and1 server at mydb.perfora.net (not localhost), so I should easily be able to run from mynewdb.mynewbox.net ... alas, I only get "Error Connecting to Database".

    One suggestion was that 1and1 may blocking the connection from that end. All ideas welcome. Thanks!

  3. Mar 26th, 2009 8:12 AM

    Thanks for the tip.. Looking to switch as soon as possible. My current dead beat host has been down 8+ hours 2 days in a row.

    FYI for anyone interested, never go with Strikedata.com

  4. Mar 20th, 2009 3:45 AM

    This is great, I have moved my blog and connected it to another database, thanks!

  5. Mar 10th, 2009 11:55 PM

    Gee thanks, I must learn how to do that because I need to move my blog to a better server :-)

  6. wvengen
    Feb 9th, 2009 3:14 PM

    This has one downside: when users dns' isn't updated yet and they visit the old site and update the site, these changes are not reflected on the new location. There are two remedies:
    1. Migrate the database and make both locations point to the same database.
    2. Allow two domains in wordpress (don't know how to do that though), create new.domain.tld to point to the new server, and redirect http://www.domain.tld to new.domain.tld on the old server. This is a new dns record which which will always point to the new server if it didn't exist beforehand.

  7. Dec 9th, 2008 8:32 AM

    This is a good post, but I am curious how the media folder is updated to accommodate this change? Since the database seems to house a the absolute path to files in the uploads folder, switching to a new host will obviously change that absolute path.

    It seems to me that unless WordPress is savy enough to update the many files in the database with the new absolute path, that all of your attachments would be missing using this method.

  8. Nov 28th, 2008 7:24 PM

    I'm not clear on moving from one C panel to another C Panel on a new server?

  9. Anonymous
    Nov 6th, 2008 1:57 AM

    @doug -

    How did you do that, Doug?

  10. Oct 24th, 2008 3:08 AM

    I moved to a new host a couple of months ago and my biggest problem was I forgot to change the config file.

    I wish I had seen this first.

  11. Oct 11th, 2008 7:12 PM

    Toi muon thu ma thoi

  12. Oct 4th, 2008 1:58 PM

    I'm planning to move my blog to a dedicated hosting site soon. My biggest concern is them trying to take over my domain name. Their tech support assured me they won't do a domain name transfer, but I'm a bit skeptical.

  13. Oct 1st, 2008 7:04 AM

    Thanks for this! So simple!

    Great job!

  14. Sep 30th, 2008 7:49 AM

    Well, I'd written a similar post and I hope you find that useful too. I loved your post title by the way and that is what actually enticed me to look at the post. Great article.

  15. Sep 30th, 2008 6:26 AM

    Good info... it's better with no downtime..

  16. Sep 29th, 2008 11:01 PM

    An awesome tutorial! Well done, and thanks for putting that together.

  17. Sep 29th, 2008 9:25 PM

    Before you start all this process, check if new host allows direct access to database server remotely. It is common that database is accessible only on localhost, for sake of the security.

    If that is the case with your new server, you would not be able to connect to database from your old site.

  18. doug
    Sep 29th, 2008 7:05 PM

    Good info. If you use cpanel and are moving to another cpanel host, you can actually transfer the new site completely from the new cpanel without downloading anything. I was able to transfer a number of wordpress sites in about 10 minutes or so with cpanel. So be sure to keep that in mind if you are pondering a switch. if you are not using a host that provides cpanel and are planning a move, make sure to seek out one that offers cpanel for management.

  19. Sep 29th, 2008 12:08 PM

    Great, I didn't know that ; /
    I made a mistake, I do everything on the same way like you sad but with no step 2 :D.

  20. Sep 29th, 2008 10:06 AM

    If you follow step 2 you will have no downtime and no lost comments!

  21. Sep 29th, 2008 9:23 AM

    Very nice and easy to understand explanation.
    Maybe its better to put some text on your site while moving it to another server, something like, please came tomorrow or under construction because i have problem with comments.
    I change my host one week ago and lose some comments. They send comments but on old host and they never came to my new site. ;)

  22. Paulux
    Sep 29th, 2008 7:08 AM

    Hi, this could be works if I migrate my wordpress site to my local machine????

    Thks

  23. Sep 29th, 2008 12:40 AM

    I am glad this helps. I am also glad to hear the site is faster for you, that was one of the main reasons I moved. The other being security issues.

  24. Sep 29th, 2008 12:29 AM

    Well done and thanks for the valuable info since I also have the intention to switch my server to a better one.

    In fact, I notice that your website now loads more quickly than before.