How to efficiently move a website from server to server?

There is always a problem with moving a website from one server to another. Transfer of files, databases, etc. is usually carried out quite efficiently – especially for smaller sites. Email accounts are just as easily moved.

The problem starts when the domain is overwritten. The DNS system works in such a way that the domain is maintained by at least two DNS servers. Going to the website, the client’s computer polls the dedicated DNS (usually downloaded automatically with the configuration of the IP address, gateway and network mask in the client’s computer). Dedicated DNS’s check what DNS servers maintain this particular domain for a given network. Local DNS’s ask one of the DNS servers maintaining the domain (so-called authoritative) on what IP the content of a given website is located. They save it in their own cache by reading the IP on which the website is located, in order to not asking for the IP for the second time when the client’s computer asks about the website again. The cache is kept by default for the time it receives from the dns servers that maintain the domain. This is called TTL (Time To Live) parameter, which by default is set on most servers to 24 hours. Thus, before 24 hours the local server won’t ask again about the IP address on which the website is located. And here the problem arises. After moving the page from the server to the server, the following things are changing:

DNS servers that maintain the domain (each server has its own DNS servers that support hosted domains)

the IP address to which the DNS servers point (i.e. the IP address of the server on which the website files are physically located)

Because when using the Internet, local DNS servers in various access networks around the world write the IP of the website (which they received from DNS servers maintaining the domain) – this address is saved to the local cache. The problem is that different servers will write the server’s IP address to the cache at different time – depending on when the client from the given network enters the domain address in the computer.

Hence the general statement that changes in DNS servers propagate on the internet for up to 24 hours – in fact for each access network it will be a different value depending on when the server’s IP has been written to the cache and how much time has passed.

So how to change your IP quickly? Relatively straightforwardly, however, you have to make some simple operations:

Since the DNS servers are usually set to TTL time for 24 hours, the operation of transferring the site from server to server should start about a day before the planned change.

Starring:

old_server – server in the sense of the IP address where the website files are located before the transfer
new_server – server in the sense of the IP address on which will ultimately be located website files after the transfer
old_dns_servers – DNS servers that maintain the domain on the old_server and point to the IP of the old_server
new_dnd_servers – DNS servers that will maintain the domain on the new_server and point to the IP of the new_server

It is necessary to:

  1. Set up hosting, upload files, set up e-mai accounts and configure the domain which we will move on (setting up the domain for hosting usually causes it to be automatically added to new_servers that automatically point to new_server
  2. Read the IP address of the old_server (eg. by issuing the “ping domain” command)
  3. Edit the DNS zone file on the new_server by changing the IP address for A record from new_server to old_server. As a result, new_servers_servers will point to the old_server, not the new_server
  4. Edit the DNS zone file on the new_server by changing the TTL parameter from the default 24 hours to e.g. 5 minutes (300 seconds). Due to this operation, the servers that downloaded the domain’s IP address will keep it in the cache only for 5 minutes, and after these 5 minutes, on the next client request, they will refer to DNS servers serving the domain again.
  5. In the domain management panel, change the dns servers that support the domain from old_dns_servers to the new_dns_servers. It should be noted that despite the change to new_servers_vers, the website is still loaded from the old_server, because the new_dns_servers also indicate the IP address of the old_server.
  6.  We leave this configuration for 24 hours. After them, we have certainty that all the servers in the world that have a domain cache have already set the TTL time not to 24 hours, but 5 minutes – so after 5 minutes they will poll the DNS servers (accurate new_servers) for the current server IP
  7. After 24 hours we can transfer files, databases, and set up an e-mail on the new_server.
  8.  You need to edit the domain zone file on the new_server by changing the A record (the one changed earlier) – by changing the old_server’s IP to the new_server’s IP.
  9.  After editing the zone file, this IP will automatically change to new_servers
  10.  After these operations, change of the IP from the old_server to the new_server should be noticeable by the world not for 24 hours, but for a maximum of 5 minutes

Notes:

  1.   Some DNS servers do not take into account TTL parameters transferred in zone files. One of such servers is a server cluster named: dns2.tpnet.pl (that is one of the telecommunication systems of Polish S.A.)
  2. Due to the fact that some servers omit the TTL parameter, it is worth to get the e-mails from the old_server after a few hours (eg by referring to it by the IP address, because the domain already points to the new_server) – sometimes some e-mail arrives.
  3. After transferring and receiving mail from the old_server, it’s worth deleting the account or at least detaching the domain and deleting the e-mail accounts on the old_server – why? Because mail servers send mail first check whether the domain to which they send mail is not local on the same server – so it may happen that on one large provider’s server will be an email sender who will try to send e-mai – and this e -mail will go locally on the old_server, even though all servers (except the old_server – locally) will see the domain on the new_server
  4. To perform the above operations you must have access to the DNS zone file editor. In many companies this is a standard service in the hosting management panel. As a standard, it is a service available in hosting based on the cPanel.
  5. You can do the above change yourself, or ask a new operator to which you are moving your website.

 

Leave a Reply