[Lxc-users] Best way to move a container

Gordon Henderson gordon at drogon.net
Fri May 7 10:18:20 UTC 2010


On Fri, 7 May 2010, John Lewis wrote:

> Hi Guys,
>
> I am trying to move an LXC container from one machine to another. Can
> you recommend the best way to do that.
>
> I have tried rsyncing but some strange things seem to be happening like
> mysql being available on localhost but the wordpress sites on the same
> machine trying to connect to localhost can't :(

I use rsync from the underlying host to the new host and not seen any 
issues so-far...

Rsync it while it's live, then shut it down it and do another sync, and 
lxc-create then start it on the new host.

Not sure why you see issues, but it might be user IDs - rsync will use 
names by default so if the names don't match on the new host or if they're 
not present then funny things might happen, so always use the 
--numeric-ids parameter to rsync.

So my rsync on the new host looks like:

   cd /vservers
   rsync -e 'ssh -c blowfish'			\
 	--stats --delete -aHx --numeric-ids	\
 	root at oldHost:/vservers/container/	\
 	newcontainer/

(I think using blowfish makes it a bit quicker - it's a lighter weight 
encryption and needs less CPU - personally, I'd rather use rsh on a 
private LAN, but that's a debate for elsewhere ;-)

Gordon




More information about the lxc-users mailing list