[Lxc-users] Best way to move a container

Brian K. White brian at aljex.com
Fri May 7 21:16:21 UTC 2010


On 5/7/2010 6:18 AM, Gordon Henderson wrote:
> 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 ;-)
>    

Why even use rsh? I just use rsync itself, no ssh or rsh. It's great.

Good call about --numeric-ids.

It should maybe be pointed out to the OP that "always use numeric-ids" 
doesn't mean always.
It means always, when doing this particular special job, where the the 
uid numbers on the files being handled by rsync do not have anything to 
do with the names in /etc/passwd of the machine running rsync.
In most normal cases, like if you were running rsync from within the 
container, you do need rsync to try to translate uid's on the fly.

-- 
bkw




More information about the lxc-users mailing list