[lxc-users] What is right way to backup and restore linux containers?
Bostjan Skufca
bostjan at a2o.si
Fri Dec 4 16:58:02 UTC 2015
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20151204/b8e9d2d3/attachment.html>
More information about the lxc-users
mailing list