Migrating an entire linux-vserver virtual server to another machine
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.







The command I used
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. :)