How to move site to another server

Here’s my algorithm of moving website from one hosting provider to another:

  1. Make sure you have all credentials needed (ftp/ssh, mysql, cpanel – whatever). It doesn’t make sense to start this process if you won’t be able to finish it.
  2. Prepare new server to host the website. Apache vhost, software versions, all modules etc.
  3. Put a website on the old host in a “read-only” mode. If it’s a forum, disable posting and write a notification to your users. You don’t want to deal with posts having same IDs on old server and on the new one. You don’t want to lose any of UGC either, so it’s better to stop users from generating contents.
  4. Copy files and databases to the new server. It’s good to have ssh access to at least one server involved in the move, it really speeds up the process. You can make a tarball and move single file instead of moving files one by one. You can use Midnight Commander to move files via FTP as well.
  5. Edit your local hosts file*. I mean file on your developer computer/laptop: you need to force your local DNS to think that you have already switched your website to the new server. Add this record ‘www.example.com 11.22.33.44′ to your hosts file. Do not touch actual DNS of your domain at this step. It’s too early to do at this point.
  6. Put something (label, background, image) on your new host to distinguish one copy of your website from another. At this stage you have two live copies of your website, you need to be able to tell the difference. One copy (old one) must be in read-only mode for your users.
  7. Test your new website now. Make sure you have edited all the configs, set up proper permissions, no software conflicts.
  8. Repeat your previous step couple of times (do not go into infinitive loop here).
  9. If you are ready to make a switch, change DNS and point domain(s) to the new IP addresses.
  10. Do not disable read-only mode on your old website. You are about to abandon that copy.
  11. New contents will appear on a new server only. Check web access logs on your old server periodically. As changes in DNS propagate, you will see that the old copy is getting less and less hits. If traffic doesn’t go down there, it means you did something wrong with DNS. Make sure you edited the zone at the proper place and actually activated it (depends on your registrar or hosting provider).
  12. If there was no hits on an old server for 24 or 48 hours, you can drop it – just make sure to download full backup from there before dropping (just in case you missed something when moving).

* Sometimes you need to edit hosts file on your server, too. For example, when you are using nginx as a frontend, you need to force your new server into thinking that your domain is actually living there, because otherwise it will try to proxy your old server and you’ll get error message like this:

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.