Using host file changes to migrate a site

The simplest way of migrating a web site from one IP to another and testing it before changing your DNS is to just change a local test PC host file.

It varies by operating system but if you change the host file and make the new IP address point at e.g. www.example.com then you can install your new content management system and add the content at your leisure by just referring to it by its normal URL.  Everyone else in the Internet gets the old site on the old IP but you (and only you) gets the new site on the new IP.

Upload your content, edit and test it as usual.

You can also test POP3 and SMTP in this same way by editing your test PC hosts file to point at the new IP address for the POP3 and SMTP addresses e.g. pop3.example.com or even webmail.example.com.

When you are ready then simply change the DNS (@) A (and AAAA) records to the new IP addresses.

Do this in two steps,

1) switch the www and similar Web site related IP addresses but keep the webmail and MX records on the OLD IP address. If the web site works as expected (remember to remove any “test” entries in your test PC hosts files) then…

2) at a suitably idle time change the Webmail and MX records. Now test the incoming and outgoing email works. On any test machines make sure that a ping to the relevant record e.g. mail.example.com or pop3.example.com returns the expected IP address.

If it is fine then after a suitably long delay you can decommission the old web site. Do this as follows,

a) backup all databases – mark them as the OLD SITE
b) backup all web site content (media etc) – mark them as the OLD SITE
c) backup any other OS specific configuration files – mark them as the OLD SITE
d) delete the old site. How you do this will vary (delete containers on VPS or reformat a server disk on standalone machines or delete the files via FTP or ssh) but never leave it hanging around.