Transfer Your Websites with Minimal Downtime using DNS and WHM

magic

New Member
Transfer Your Websites with Minimal Downtime using DNS and WHM

Warning: Your use of the directions in this post is entirely at your own risk! The author will not be held responsible for any damages or loss/corruption of data as a result of following these directions. Author is not affiliated with KnownHost in any way.

PLEASE read this guide in full BEFORE you take any action described here.

Before You Begin
This guide will help you move a website from your old server provider to your new KnownHost server with minmal service disuption. In order to use this guide, you must meet all of the following requirements:
  • You must be the root user on BOTH the new and old servers.
  • Both servers must have a recent version of cPanel/WHM installed and working.
  • You must be able to keep the old server online for approximately 3-4 days after you are done transferring (meaning you're not being immediately disconnected).
  • You must have a sufficient level of experience with server administration to follow these directions. If you read something here and say "woah what now?" then you are probably ill-suited to do an operation like this.
When you transfer a domain, you have to go to the domain name registrar and update the IP address entries for the domain's name servers when you were done transferring the account's files. The process of updating those entries across the global DNS network can take up to 48 hours depending on the circumstances surrounding your domain and the condition of the network.

While you still need to do this process to have your domain's name servers permanently moved to your new server's addresses, this guide will help you avoid the "up to 48 hour downtime" scenario when you transfer a domain. Instead of waiting for the changes to your domain's name servers to propagate through the global DNS system, you will use the old server's DNS server (presumably BIND) to act as a connection relay to get your visitors to their correct destination on your new server.

Throughout this guide -- to keep things straight -- I will use the terms Old Server and New Server when giving directions (note the colors).

This guide will show you how to transfer a single domain. To move multiple domains, simply repeat these directions for each domain to be moved.

These steps are only effective if you follow them before you transfer a domain.

Before you begin this operation, both cPanel installations should be updated to the most recent version on their branch as this often will avoid transfer problems.

Determine the Domain's Existing DNS Settings
On the Old Server, go to the WHM for the server, which should be accessible at:
Code:
https://hostname:2087/
(replace "hostname" with the hostname of the server)
On the main screen that appears, find the DNS Functions button and click on it. On the next screen that appears, click on the Edit DNS Zone button.

Next will be a screen that shows all the available domains. Choose the domain you want to start with, select it, and click on Edit.

This is the DNS screen for this domain. There will likely be many entries here underneath the zone file header. Each of the entries will look similar to the following:

[Broken External Image]:http://img250.imageshack.us/img250/6681/image4hn5.gif

The first box is the name that is being defined. The second box defines the "time to live" or TTL value for that name. This value exists to help DNS clients cache information about internet names so that they do not need to constantly ask the DNS servers for the information they need to make connections. The third box is a drop-down that defines what kind of record this is (more on this in a moment). The fourth box (in all records except MX records) defines the value of the record, in this case and IP address (in MX records there is a fifth box which is the value).

There are various types of DNS records (you can see them all in the drop-down box). It is critically important that records maintain their proper type, so don't change any of them. The records we will deal with in this guide are A entries. A entries take a name and turn it into an IP address. The A entry for the domain is pictured in the example above. The domain itself and each subdomain will have an A entry at least.

You need to find the A entry in the list for your domain (as like the one pictured above). Do not change anything! You're just looking for information at this point. What is important that you find is the TTL value for that A entry. In addition, if you have any sub domains, find those TTLs as well.

The TTL value is the number of seconds that a DNS client will cache the information in that record before it expires and the client must ask the server for new information. Common values for A entries are 86400 seconds (24 hours) or 14400 seconds (4 hours), depending on the type of entry it serves.

The maximum value of the TTLs you have collected will determine how long you must wait before you begin your transfer. If you are a little slow at division, you can use Google's calculator to show you what 86400 seconds in hours is (replace 86400 for the value you have to convert).

So now you know the number of hours? Good.

For this example, we will presume that the maximum TTL on an A entry on our domain is 86400 seconds or 24 hours.

Now -- we are still on the Old Server DNS screen for this domain -- for each of the A entries, replace 86400 or 14400 with 900 (which is 15 minutes) and save the changes to the DNS zone. Be careful! Only change the TTLs for the A records, not any other data.

What this does is says to DNS clients: the next time you check in with us (up to 24 hours since the last time you did), we want you to start checking in with us more frequently, 15 minutes to be exact, for updated DNS information.

Now, go ahead and logout out of WHM. You must now wait at least 24 hours (or however long the maximum TTL was) before you proceed to the next step. This will allow time for all of the millions of DNS clients out there to allow their existing record for your domain to expire as scheduled.

The next time a user wants to access your domain, the DNS client will sense that it has expired information and ask the server for new data. When the new data is sent to them, the new expiration schedule is included, which will make the data expire very quickly and require the client to check in more frequently.

While you are waiting, use this time to make the New Server production-ready, meaning that you have your web server, database, and any other servers you need completely set up, configured, and ready to go (waiting for your account data). The less you have to do later, the less downtime there will be.

Conducting the Transfer
Now that you have waited the amount of required time, you now can begin working on the transfer itself. First of all, you need to determine is the domain you are transferring is a static website (where the content is not dynamically generated or stored in a live database) or a dynamic website as this will affect your next step. In general, all PHP/MySQL style websites are dynamic in nature.

If the website is dynamic, you want to make sure that the database entries and files themselves are not going to be changed during the transfer process as this will leave behind new content on the Old Server. So you will have to close the website to its users to prevent any changes from happening. The most graceful way of doing this is to replace the index file in the public_html directory with a notice saying that the website is being moved and that it will be back online in a short while. If for whatever reason you do not want to do this, you can suspend the account through WHM instead (although this will leave a user-unfriendly message to the visitors).

If it's a static website, this is not necessary. You just have to make sure the website owner is not making any changes to the static files (through FTP) while you are doing the transfer. At the end of this process, it will appear as if there was no downtime at all on a static website.

To transfer the files easily, you will use WHM's transfer facility. In order to do this, the firewall on the New Server must have the SSH port of the Old Server open. So for example, if the SSH port of the Old Server is 22, then the firewall on the New Server must have port 22 open for the duration of the transfer (although you can close it again when you are done). Directions on how to do this will depend on the firewall you are using, if any. Check your firewall documentation for more details. Remember to reload your firewall rules!
 
Once you are sure the necessary port is open, go to the New Server WHM. On the main page that appears, click on Transfers. Next click on Copy an account from another server.
  • The Remote Server Type should be WHM 4.5 or later assuming the other server is a recent version of WHM.
  • Enter the IP or hostname of the Old Server in the address box and the SSH port in the port box.
  • Compressing the transfer requires a lot of CPU on both ends and the default is to not compress.
  • Enter the user name of the account as it is on the Old Server. If you want change the user name you can do so in the next box, otherwise leave it blank. If the domain was on a dedicated IP and you want to preserve that, check the box for it. Similarly, if the account was a reseller, check the box for that as well.
  • Under Authentication, choose Login as Root and then for the method choose Password. Enter the root password for the Old Server in the last box and then submit.
Now sit back and watch as the transfer tool does all the hard work for you. If for whatever reason it cannot connect to the Old Server, that means the SSH port you defined is not open. Go back and check it again. If you have any other problems during this process, file a support ticket and the guys will be happy to help you out.

Once the transfer is complete, you can check to see if the website is working properly on the New Server by going to the following address:
Code:
http://new-server-ip-address/~username
(replace "new server ip address" with the IP address of the [COLOR=RoyalBlue]New Server[/COLOR]
and "username" with the user name of the account, but keep the ~ before it)
This should show you the transferred website (assuming you have not disabled this feature through the WHM security settings. Check to make sure that everything is back in place. If you had disabled the website previously, enable it again now. Make sure that any databases were moved properly and are functional.

In the New Server WHM, go to the DNS page for the domain and check that all the appropriate entries were moved over properly. These entries must go back to using the normal TTL values (86400, 14400, etc) so do NOT use the shortened values here. If necessary, change the TTL values for the A entries to their normal, longer values. Ensure that all A entry IP addresses are the ones that are used on the New Server and not any of the old IP addresses.

Set Up the DNS Relay
In a new browser window (keeping the other one open), go to the Old Server WHM and go to the DNS page for the domain. These values should continue to use the shortened value (900) as you left it before. Now go to the A entry for the domain and change the IP address value (the last box on the right) to the new IP address for the domain. Make similar changes to any subdomain IP addresses.

For example, if the Old Server IP address for the domain is 192.168.123.456 and the New Server IP address for the domain is 192.168.789.000, then you would change the value of the DNS A entry to 192.168.789.000. Check everything for accuracy and submit.

At this point, this is what the process of a user connection is like:
  1. Visitor enters domain (example.com) into browser.
  2. The domain name name server entries (which have not been updated yet) point the user to the Old Server.
  3. The Old Server says: The domain is at 192.168.789.000, which is the address at the New Server, so go there and remember this for the next 15 minutes.
  4. The New Server says: The domain is here.
Now, assuming that everything is working properly and the website is back online, you can then proceed to the next step, which is to go to the domain name registrar for the domain name and request that the name servers for the domain be changed to the new values on the New Server.

While this process is going through the system (about 48 hours), the Old Server acts as a connection relay to get users to the New Server. Therefore, you need to be able to keep the Old Server online for the duration of this process, which is at least two days. I would suggest keeping the server up for about 4 days to ensure maximum connection success. There really is no rush here, so make sure that your domain fully resolves properly before pulling the plug on the Old Server.

A tool that is helpful to determine how the process is going is the "ISP Cached DNS Lookup" tool on DNSstuff.com (scroll down to find it). Give it about 24 hours first, and then enter the domain name in the box and choose NS from the drop down list. This will generate a big list of ISPs and their cache status for the name servers for your domain. If one of them says "No cached answer: would go to NS of..." that means that they have no saved information and will get the new IP addresses faster. As you can see, there is a lot of inconsistency between providers and this accounts for the long delay in getting new name server addresses propagated.

You can also use the "DNS Lookup" tool to see how your A entry or NS entries are set. This data is in real time and should point out any errors.

Once the relay is in place and the website is working properly on the New Server, you can terminate the user account on the Old Server and delete any remaining user files on the Old Server.

If you are successful in this process, for a dynamic website the amount of downtime will be limited to the time you have to close the website to conduct the transfer, and on a static website the transfer should appear seamless.

And that's it!
 
Excellent tutorial. I would add one other recommendation. There is also a brief period of time when user's email may be sent to the old server after the account has already been copied over to the new server. To avoid 'losing' those emails it is a good idea to shutdown the mail server (i.e. exim) for that 15 minute window. That way emails will remained queued for delivery to the new server.
 
Excellent tutorial. I would add one other recommendation. There is also a brief period of time when user's email may be sent to the old server after the account has already been copied over to the new server. To avoid 'losing' those emails it is a good idea to shutdown the mail server (i.e. exim) for that 15 minute window. That way emails will remained queued for delivery to the new server.

thanks so much for useful info
 
Search the forums and couldnt found any answers.Is there any easy way?
 
Top