Total Pageviews

Friday, 22 June 2018


In order to migrate the files on a VPS box from one provider to another, one of the best solutions for the job is to use a tool called Rsync.
Let’s take a closer look at Rsync and see how it can help you rapidly move virtual private servers from one provider to another.

About Rsync

Rsync is one of the most common ways to copy/backup/restore files and folders between two locations, regardless if these endpoints are local or remote servers.
It supports compression, encryption and incremental transfer which makes the app an extremely versatile and useful tool for systems administrators.
Note: Running Rsync does not require you to be logged in as root.
Since Rsync supports incremental file transfer, the first time you will run it, it will require the same time to copy all the files as any other command However, when you subsequently execute Rsync, it will determines which changes have been made and only transfers those files.
This mechanism is designed to save time for the system admin, load and bandwidth.
Getting Acquainted with Rsync
Let’s get started and copy our live running server in a new location in 5 easy steps.
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:
uname –a
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!
ssh user@oldserver
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:
which rsync
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/sysconfig/network-scripts/* (CentOS distros)
/etc/network/* (Ubuntu distros)
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 --numeric-ids --exclude=/etc/fstab  --exclude=/etc/network/* --exclude=/proc/* --exclude=/tmp/* --exclude=/sys/*  --exclude=/dev/* --exclude=/mnt/* --exclude=/boot/* /* root@target-server-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.
(Tutorial written by a contributor)


登陆source server,然后运行:
rsync -avz -e "ssh -p target-server-ssh-port" --numeric-ids --exclude=/etc/fstab --exclude=/etc/network/* --exclude=/proc/* --exclude=/tmp/* --exclude=/sys/* --exclude=/dev/* --exclude=/mnt/* --exclude=/boot/* --exclude=/etc/udev --exclude=/etc/netplan/* --exclude=/etc/sysconfig/network-scripts/* --exclude=/etc/systemd/network/* /* root@target-server-ip:/


No comments:

Post a Comment

Note: only a member of this blog may post a comment.