Home Company Services Portfolio Contact us nav spacer

Migrating an entire linux-vserver virtual server to another machine

by Izak Burger posted on Jun 23, 2009 12:42 PM last modified Jun 23, 2009 12:42 PM —

I always forget the exact rsync command used for this purpose. Here it is for me and the rest of the world too.

The method I use is to rsync the whole machine to the new location while it is still running, then take it down, rsync it again, and bring it up in the new location.

Because we do not allow root logins, we also need to add sudo to the mix, and a few other options. The whole command is:

  rsync -aH -v -e ssh --rsync-path 'sudo rsync' \
  --numeric-ids --partial --delete \
  /var/lib/vservers/vsname/ \
  myuser@remotehost:/var/lib/vservers/vsname/

The --rsync-path option is required to use sudo on the other end. --numeric-ids is important, otherwise rsync resolves uid's using /etc/passwd and /etc/group, which may differ on the host. -a puts it in archive mode, which preserves links, permissions and ownership, and -H also preserves hard links. --delete tells rsync to delete files on the remote end that are no longer available locally.

You also need to set up the required files in /etc/vservers of course.

Document Actions

The command I used

AvatarPosted by Daniel15 at Feb 15, 2010 07:50 AM
When I was moving servers, I used a similar command. The vserver command has the ability to create a vserver from a rsync source. Also, I have SSH password authentication turned off, so was using a temporary SSH key called "migration" to move data across the servers. In the end, the command I used was:

vserver vsname build -m rsync --hostname vsname.example.com --interface eth0:208.77.188.166/24 -- --source root@remotehost:/var/lib/vservers/vsname -- -avzh -e "ssh -i /root/.ssh/migration" --progress

Just thought I'd post this comment here in case it helps anyone else. Found this post while searching for some Linux-Vserver stuff. :)

Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
Tell us your name.
(Required)
Enter your e-mail address.
(Required)
(Required)