[Lxc-users] lxc containers as backup 'replicas'

Serge Hallyn serge.hallyn at ubuntu.com
Wed Jun 5 12:34:48 UTC 2013


Quoting Rory Campbell-Lange (rory at campbell-lange.net):
> Following the pretty successful tests** I've been making of using lxc
> containers I'd be grateful for some advice on using lxc containers as
> backp 'replicas' of running machines, to bring up in case the main host
> fails.
> 
> **(I've been on the list to discuss routing problems which I've solved
> temporarily by turning off kernel ethernet filtering -- still an issue
> in discussion).
> 
> There are 4 parts to a running machine that I will need to replicate to
> a lxc container, which I intend to do nightly. These are:
> 
>     1. etc configuration (we back config files up through etckeeper)
>     2. binaries (we're happy with a dpkg -l listings here)
>     3. run-time config for web apps (we back up through a file backup)
>     4. database backup (backed up via log shipping)
> 
> I'd be grateful to know if it is possible to sync 1. and 3. into the
> container when it is not running. In other words, to simply update the
> config files in /var/lib/lxc/<container>/rootfs/etc, for example?

If the source is still running then I suppose depending on the
application some of the source files could be in a transient,
inconsistent state.

> On another point I'd also like to know of the recommended way of using
> another mount point for lxc containers and the dpkg cache. For example,
> I wish to hold my containers in /dev/sdb/ mounted on /containers. Should
> I symlink /var/lib/lxc/ to this mount point?

If you're on a new enough lxc (i.e. 0.9.0) I'd recommend using lxcpath.
You can set 'lxcpath = /srv/lxc' in /etc/lxc/lxc.conf, then all
containers will be created and run from /srv/lxc instead of
/var/lib/lxc.  Or you can just add '-P /srv/lxc' to all lxc-* commands.

> Finally I'd be grateful to learn of people's experiences with btrfs for
> snapshotting and managing containers. I personally use it for my laptop
> backups, but my host server is on a 3.2.0-4-amd64 kernel which is pretty
> old by btrfs standards.

yeah I don't know that I'd trust it under 3.2.  I think 3.5 is where it
stopped losing data for me.  But best to run some tests.  When it
failed me, it generally did so after one or two subvolume commands.

-serge




More information about the lxc-users mailing list