Efficient server Migration for Dynamic Website

If you maintain a website,
you may have to change you current hosting server for many reasons. It
may be that, their service is not good or uptime is low or you may
consider to go a server with better facilities or even you may move to
your own VPS/Dedicated server. All of the these requires that you move
your current website to the new server.

But problem arises as you update the nameserver for your domains to
point to new server but the new name servers do not propagate world
wide. In this case, some people will see the website from the old
server while some from new server. If it is a dynamic site like forum,
blog etc. when propagation is complete, its sure that some users will
complain that their posts/contents are missing.

It is because the visitors who visited the website from old server
submitted the contents there. But when they are getting the server from
the new server, they will not see the contents as you did not sync it.
And often, its not easy to sync from server to server.

You may say, its better that I put the site in maintenance mode in old
server after copying the data to new server so that this does not
happen. Yes, its an alternative. But dont forget to give a notice in
the old site that you are migrating the server.

Still, there are problems as you may loose visitors. They may not come
to your site again seeing it is down. This may be happens mostly for
new comers.

Recently I faced such an issue while I was moving a forum which I
maintain. It is Projanmo Forum (http://forum.projanmo.com). I just
share with you the methods I have followed. Yes, I did not miss a bit
of data except I forgot to copy a folder from old to new which I had to
do later. Yes, my visitors/members also were not aware of such
migration except I put the forum for maintenance just for 10-15
minutes.

So the followings are steps I have followed and recommending to those
have not any better option. I assume that your site is a database
driven site.

Preparation of Migration:
You should start your preparation about three days before the final
schedule. If you are migrating to a shared server, consult your hosting
company
and make a schedule for migration considering the convenient of both.

  1. If you can edit the DNS Zone of you domain, change the all TTL of your name server to 300 (300 seconds i.e. 5 mins). You can find it easy If you use WHM.
  2. Give an announcement in your site, that your website will go maintenance mode for xx minutes on xx date.

On the migration day:

  1. Consider the most off-pick hour of your website.
    That is when there are no or less hits to your website. It may be after
    midnight or something else.
  2. Pack your whole site (home directory) and send it to new server. If you use cPanel, then use its Backup Feature. If you have root access to new server then use Remote Backup (SCP) method and transfer to /home directory. I like it most :). Otherwise, you may use Remote FTP.
  3. Put your site in maintenance mode.
  4. After completion of transfer, restore it in your new server. Here cPanel will save your life (if you old server also had cPanel). Just one click will restore the whole site as it was in old server. This may be true for other control panel too. But so far I have used only cPanel. I think, if you own WHM, you know how to restore a Backup. If you dont know click “Restore a Full Backup/cpmove file”.
  5. Now an access host to be added to mysql server. Get the IP of old server and add it to your new servers mysql. You can also do it via cPanel’s Access Host links
  6. Now login to your old server and edit the the
    configuration file where your site’s database configuration is stored.
    Suppose it is db_config.php. You should get the database host there
    which usually is localhost or IP. Now you just replace it by your new server’s IP (or mysql server’s IP).
  7. Now your site in old server should be able connect
    to the database of new server and your site is UP because maintenance
    configuration is stored in database and as database is now on new
    server, where maintenance mode is not enabled.
  8. Now go to your domain registration panel. Their update the nameserver of your domain name by new server’s names.
  9. Edit the DNS zone in new server and change TTL to normal values like 14400 or larger. Otherwise it huge increase server load.
  10. Again edit DNS zone of old server and change all A records. The exisiting A records are IP of old
    server. Change it to the IPs of new server. This will tell the DNS
    queries that the site is new server 🙂 .
  • I like very much the
    I like very much the writings and pictures and explanations in your adress so I look forward to see your next writings. I congratulate you.