Step 1) Ensure that your OS is in Place In order to migrate your server to a new location, the first step is to install your operating system onto new infrastructure. You can determine what architecture your current server is running on with the following command:
You will want to use a Linux distro and kernel as close as possible to the one installed on server you are migrating. Most VPS providers will set this up for you when you buy your new VPS server. Tip: You may only need to do this step if you are building out a server locally. Hypervisors such as VMware help administrators streamline the process of installing operating systems onto hardware. Step 2) Check the connection between the 2 servers Once you have the two systems up and running you will need to check to see if it will be possible to make a connection between the two servers. You can easily do that with the command “ssh”. Assuming you are running SSH from the new server and trying to connect to the old one, if the old server asks for the password, you passed the test!
Step 3) Check Rsync At this point you will have to verify that Rsync is installed on both systems and if not, it’s time to install it. You can check if the command is present in the following way:
In case the tool should not be present, you can easily install it using the following commands:
apt-get install rsync (on Ubunbu based distros) yum install rsync (on CentOS based distros)
Step 4) Prepare the Exclude List You will now only need to decide which directories to exclude. This may vary from system to system, but I would never suggest you to include the following unless differently needed:
/etc/fstab /etc/sysconfig/network-scripts/* (CentOS distros) /etc/network/* (Ubuntu distros) /proc/* /tmp/* /sys/* /dev/* /mnt/* /boot/*
Step 5) Run Rsync Some VPS administrators may be worried about running Rsync while a MySQL instance running. In most cases, this won’t present a problem. You might consider running it outside of heavy load periods if your server is hosting a live system, but other than that you should not have any problems. Of course you will not have a consistent copy of the DB unless you stop the service before beginning Rsync, so please keep that in mind. In this instance, Rsync will create a copy and it will allow you to test the system on the new server, which is usually always a big plus. An Example of Rsync at Work Assuming you are logged into the destination server, you’d implement a command that looks like this:
rsync -auHxv –numeric-ids –exclude=/etc/fstab –exclude=/etc/network/* –exclude=/proc/* –exclude=/tmp/* –exclude=/sys/* –exclude=/dev/* –exclude=/mnt/* –exclude=/boot/* –exclude=/root/* root@SRC-IP:/* /
Once it finishes, simply reboot your destination server and you will notice that you will have a precise copy of the files located on your source VPS.