Server upgrades

I am in the process of upgrading the servers on the JC-J.COM network from Linux ubuntu 10.04 (Lucid Lynx) to Linux ubuntu 12.04 (Precise Pangolin) . Not all of the servers are running ubuntu, however this is one of the main distros currently being used. In addition, some other servers on the network are running the Linux distros CentOS or Debian.

There are many different distros (distributions) of Linux and, for the uninitiated, this can be somewhat confusing. DistroWatch lists 144 active Debian derivatives and this number is increasing. The Top 10 are described by DistroWatch here.

Downtime during this upgrade process is being kept to a minimum, although some downtime is usually unavoidable, because ubuntu 12.04 is a major release with significant differences. Unfortunately, the upgrade path does not always run smoothly. If that happens, it then becomes necessary to make a fresh install of the new OS.

Ideally, this fresh install utilises a minimal template so that you can re-build the server in the way you want. This deletes everything on the server and you need to restore all the non-OS related applications from backups. Typically, it is necessary to restore the control panel, PHP modules and directories containing the websites and associated databases.

The main Unix commands used in this process are ‘tar’ for creating and restoring the archive backups. ‘Rsync’ for copying the archives to remote servers. This is just one way of doing it.

For example, to create an archive of the root directory using a command line in a terminal, e.g. using SSH:

tar -cvpzf /backups/`date +%Y%m%d`_nsXXjc-jcom.tar.gz
--exclude=/backups/`date +%Y%m%d`_nsXXjc-jcom.tar.gz
--exclude=/proc
--exclude=/sys
--exclude=/mnt
--exclude=/media
--exclude=/run
--exclude=/dev
/

Reference: Introduction to tar

To transfer a backup from a remote server to the server with the fresh install of ubuntu 12.04. This would be the backup of an ubuntu 12.04 server with control panel, extra PHP modules, Apache web server modules, etc. In my case, I created it on a separate cloud server that can be shut down or even destroyed after it has served it’s purpose.

rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
--progress /root/20131228_nsXXjc-jcom.tar.gz xxx.xxx.xxx.xxx:/root/

It uses public SSH keys with no password. For the above rsync to work, you firstly generate a private / public key pair on the origin server and place the public key on the destination server where the backup is being copied to. This enables the two servers to communicate securely through an encrypted SSH channel without requiring any intervention.

Reference: rsync

To restore the above backup to the server with the fresh install of ubuntu 12.04:

tar -xvpzf /root/20131228_nsXXjc-jcom.tar.gz -C / --numeric-owner

You might have a separate backup of the websites, virtual domains and associated databases and these would be restored afterwards.