In this week Tech Talk I am going to focus on the proper way to transfer a live website from one host to another. I hear horror stories all the where even “hosting companies” do not do it properly. I am going to assume you do not have access to, or want to use a Control Panel migration like cPanel or Interworx, If you have those system see their instructions for moving, referring here for DNS changes and Register Changes only.
The first thing you should be aware of is that moving a site is a multiple day process in order to ensure proper and limited or no service interruption.
If your planning on changing your registration company for your domain name, I recommend you do that before moving the actual web site, this will make things go much smother, It can take up to 3-4 days for a Transfer to complete, each registrar has a different process for Transfers so ask the company your moving the domain name TO for help, many times they can walk you through step by step what to do in order to move your domain name to their services.
Whats in a name?
The next step is to recreate the current Dynamic Name Server (DNS) records at your new hosting provider. If you use an external (not with your current hosting provider) you can skip this. You need to set up each A , CNAME, MX, SOA, and other DNS Records on the new DNS Server, for now just Duplicate them Exactly as they are. Most hosting providers have an interface for you to view these records, if not ask your current hosting provider for a list
Time to LIVE!!!
Now this is the most important step, many hosting companies do not do this step and it really matters, You need to Adjust the Time to Live, or TTL, for each record, during the Transfer I normally set it to 300, which is 5 mins, meaning other DNS servers will only save or cache the record for 5 mins, standard is 4 hour to 12 hours.
The TTL time is listed in seconds.
Update the Name
Now you need to go to your Registrar and change the Name Server Records to your new hosting company (again skip this step if you use an external DNS system). Once you change these records your new hosting company will be directing the traffic for your sites, if you followed the the steps above nothing should change for your sites visitors, their computers will simply be getting instructions from a different place
Now wait 36-48 hours before going to the next step, this will allow the name server changes to propagate worldwide.
But what about the files
You probably wondering why I have not even transferred even a single file yet, well we are getting to that, at this point you can use what ever transfer method you have available, FTP, sFTP, SCP, etc, to move all of the files from your old host to your new host. If you have a control panel like cPanel, or interworx you should be able to import and export directly from those system, even if your moving to a different control panel many have importers that will read the export from other systems.
If you do not have a control panel you need to move everything under the “public_html” dir to the new “public_html” dir (this is also called www in some places) if you have subdomains those could exsist out side of this dir and should be moved as well.
Also create a copy of any Databases, Set up the databases and database users on the new server and import a copy of the databases in to the new server. mysqldump is great for this.
Warning: Some applications do not have portable passwords, if you these apps new passwords will have to be generated for all users
At this point DO NOT transfer any emails or maildir’s, we will do that later.
Test, Test, Test
Now we need to test the site(s) to make sure it works on the new server, the best way to do this is to manually edit your PC’s “Hosts File” On windows it located at “C:\windows\
system32\drivers\etc\hosts“ on linux/unix it is located at “/etc/hosts“ edit as admin/root this file to add
#new.ip.add.ress mydomain.com 22.214.171.124 example.com
This will force your site to be directed to your NEW server, Test your site, correcting any errors. After your satisfied that your sites work properly on the new server then remove that line from the hosts file to make sure everything goes back to normal, you will now be viewing the site on the old server. It is a good idea to Change something, add a post, or add a header to the new and old site to indicate what is being served. This allows you to know what server your looking at.
Email, What email?
Now you can set up all of the email accounts you have on the old hosting company, if you use IMAP do not move any mail yet, we will do that last.
Lets get the move on?
Now it is time for the big move, It is best to do this when you have the LEAST amount of traffic for alot of sites that is around midnight but some sites see their peak at midnight so it is not a one size fits all, doing it when you have the least amount of traffic is always best.
Put all of your applications, forums, blogs, etc, in to “Maintenance mode” or somehow make them Read only so no new content is posted to the sites
Download a fresh copy of all the databases, and import them to the new server, replacing any data already there.
Change the IP Records in all of the DNS Zones, to the new server, it should only take 5 mins if you followed my advice from step one for it to be live for EVERYONE.
Take the Sites out of maintenance mode (this should only be applicable to sites that store the settings in the database, sites with file based settings should automatically return to normal mode)
Check to make sure your site is being present from the new server (you can look at access logs, databases activity, use iptools.com to check the dns records etc to ensure this)
OMG my Mail is GONE, I Hate you!!!
Email should now also be arriving on the new server, if you use IMAP you might be scared that “all your mail is gone” but fear not, Log back in to your old server, probably need to use the IP address instead of the domain name now. Find the Mail Directory, Nomally just called “mail” inside that will be a folder for every email account, you should find the same structure on the new server, simply transfer the files from 1 server to the other for each mail box and your mail will be back like it was never gone, we do this last to ensure no mail was lost in transition.
Time is far to Short…..
Now we need to go back to the DNS Records and change the TTL again, this time back to the normal rate of 4 to 12 hours, I recommend 4 hours, value 7200. This will lessen the load on your name server. Remember TTL is stored in Seconds, so if you want anything different than 4 hours (7200) you need to do the math
WHOA, Am I done yet
Test everything, if everything works fine you have successfully transferred your site
Shameless Plug Alert!!!!!
If you need help moving a site, even if you are not and never been a MP Technology Company, We offer Consulting Services to everyone, so we can professionally move your site to any vendor from any vendor for you, for a nominal fee.