[lxc-users] What is right way to backup and restore linux containers?

Saint Michael venefax at gmail.com
Sat Dec 5 02:33:45 UTC 2015


I normally copy containers with rsync, to a different server, and with
plain "  cp -dpR --sparse=never" in the same box. Should I use tar instead?
I noticed that rsync is slow, even in the same network

On Fri, Dec 4, 2015 at 3:04 PM, Mark S.S. Slatter <mslatter at maximumcomm.com>
wrote:

> For what it's worth, my notes from various research indicate:
>
> ======= MOVING LXC CONTAINERS =====
>  When moving from one server to another, important NOT to copy it.  All
> permissions
>  inside container must be preserved.  This is done by the following:
>
> On OLD server
> tar --numeric-owner -czvf mycontainer.tgz /var/lib/lxc/my_container
>
> On NEW server
> tar --numeric-owner -xzvf mycontainer.tgz -C /var/lib/lxc/
>
> Be sure to set the appropriate IP address info on new location if it will
> change.
> ==============================
> I believe this is what I used the last time and it worked.
>
> Thanks,
>
> Mark.
>
> On Fri, Dec 4, 2015 at 12:43 PM Bostjan Skufca <bostjan at a2o.si> wrote:
>
>> "man tar"
>>
>>
>> https://www.google.si/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=tar%20preserve%20everything
>>
>> I would suggest -p and --numeric-owner and maybe --acl and --xattrs, but,
>> as I said before, I generally use rsync.
>>
>> b.
>>
>> On 4 December 2015 at 18:20, Saint Michael <venefax at gmail.com> wrote:
>>
>>> What would it be the right tar parameters to compress and decompress all
>>> the rootfs, including devices and special files?
>>>
>>> On Fri, Dec 4, 2015 at 11:58 AM, Bostjan Skufca <bostjan at a2o.si> wrote:
>>>
>>>> Depends if you need consistent copy and how much downtime you can
>>>> tolerate.
>>>>
>>>> If inconsistent copy is enough, then you can run rsync over storage of
>>>> running container (on host, not in container) and be done with it.
>>>>
>>>> Rsync:
>>>> I find rsync useful and fast, providing that:
>>>> - whole container filesystem metadata fits into memory
>>>> - not too much data changes between subsequent rsync runs
>>>>
>>>> So, my simplified procedure is:
>>>> 1: rsync #1 - does most of the work, takes time, but can be run on
>>>> running container
>>>> 2: rsync #2 - to see how much files have changed since initial run
>>>> (gives good estimate of upcoming downtime)
>>>> 3: lxc-stop -n container (on host 1)
>>>> 4: rsync #3
>>>> 5: lxc-start -n container (on host 2)
>>>>
>>>> This procedure gives me about 10 seconds of downtime for containers
>>>> with small filesystems (up to 50GB).
>>>>
>>>> Block device migration:
>>>> Rsync is fast if it operates on not-too-many-files. If you are getting
>>>> long rsync runs because of amount of small files, then you might be better
>>>> off migrating whole block device. You can go about it with LVM or btrfs
>>>> snapshots too. I do not usually use this.
>>>>
>>>>
>>>> LXC vs LXD:
>>>> LXC in generally single-host-centred, so you have to do things manually.
>>>> LXD on the other hand supports operations on multiple hosts, but others
>>>> are more qualified to summarize what is currently possible (creating LXD
>>>> host associations between on-premises and cloud-provider hosts etc.)
>>>>
>>>> b.
>>>>
>>>>
>>>>
>>>> On 4 December 2015 at 17:32, Saint Michael <venefax at gmail.com> wrote:
>>>>
>>>>> I was going t ask the same question.
>>>>> It  is a very important one. I am moving containers via rsync, but it
>>>>> takes tooo long.
>>>>>
>>>>> On Fri, Dec 4, 2015 at 11:03 AM, Eax Melanhovich <afiskon at devzen.ru>
>>>>> wrote:
>>>>>
>>>>>> Hello.
>>>>>>
>>>>>> Lets say I have some container. I would like to run something like:
>>>>>>
>>>>>> lxc-backup -n test-container my-backup.tgz
>>>>>>
>>>>>> Then move backup somewhere (say, to Amazon S3). Then say I would like
>>>>>> to restore my container or create its copy on different machine. So I
>>>>>> need something like:
>>>>>>
>>>>>> lxc-restore -n copy-of-container my-backup.tgz
>>>>>>
>>>>>> I discovered lxc-snapshot, but it doesn't do exactly what I need.
>>>>>>
>>>>>> So what is the right way of backuping and restoring linux containers?
>>>>>>
>>>>>> --
>>>>>> Best regards,
>>>>>> Eax Melanhovich
>>>>>> http://eax.me/
>>>>>> _______________________________________________
>>>>>> lxc-users mailing list
>>>>>> lxc-users at lists.linuxcontainers.org
>>>>>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> lxc-users mailing list
>>>>> lxc-users at lists.linuxcontainers.org
>>>>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> lxc-users mailing list
>>>> lxc-users at lists.linuxcontainers.org
>>>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>>>
>>>
>>>
>>> _______________________________________________
>>> lxc-users mailing list
>>> lxc-users at lists.linuxcontainers.org
>>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>>
>> _______________________________________________
>> lxc-users mailing list
>> lxc-users at lists.linuxcontainers.org
>> http://lists.linuxcontainers.org/listinfo/lxc-users
>
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20151204/c6b07f73/attachment-0001.html>


More information about the lxc-users mailing list