Here’s my algorithm of moving website from one hosting provider to another:
- 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.
- Prepare new server to host the website. Apache vhost, software versions, all modules etc.
- 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.
- 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.
- 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 220.127.116.11′ to your hosts file. Do not touch actual DNS of your domain at this step. It’s too early to do at this point.
- 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.
- Test your new website now. Make sure you have edited all the configs, set up proper permissions, no software conflicts.
- Repeat your previous step couple of times (do not go into infinitive loop here).
- If you are ready to make a switch, change DNS and point domain(s) to the new IP addresses.
- Do not disable read-only mode on your old website. You are about to abandon that copy.
- 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).
- 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: