Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Backup Strategy for Container Host #1304
Comments
|
A complete backup of /var/lib/lxd and separate SQL dump of the database would be the easiest way to backup everything LXD cares about. |
|
You may also consider backing up /var/log/lxd/ if those logs matter to you, LXD won't mind if they're gone though. |
|
Sounds good. Thanks. :) |
srkunze
closed this
Nov 11, 2015
|
Can /var/lib/lxd/images be excluded from backup? Or do containers reference images which they are created from? |
srkunze
reopened this
Nov 11, 2015
|
If you're using zfs, the containers do reference their image, for other backends, they don't, though if you decide not to backup the images, you should also clear the image related tables from the database on restore. |
|
I understand. I pondered over this in order to reduce the backup size. As it seems, though, using ZFS would be an even better way of optimizing backup size without the need to introduce some exceptions and other weird hacky things. |
srkunze
closed this
Nov 11, 2015
|
Correct. If using zfs you'll want to backup the zpool separately, that will contain all containers, images and snapshots, then /var/lib/lxd itself will be mostly empty except for the database and certificates. |
|
Haven't made experience with ZFS, yet. Seems like a good alternative. |
yoniy0
commented
May 20, 2016
•
|
@stgraber do you mind correcting me if I'm wrong on any of the following, and clarifying a few points? If using ZFS as storage backend, then LXD creates the following data-sets: Using One could use Would a feasible restore strategy then be simply sending all snapshots in the reverse direction? Would LXD accept the new data, or should it be manually made aware of it? Finally, are any parts of |
CalebEverett
commented
Jun 9, 2016
|
Here's one approach using aws volume snapshots:
It also seemed like you had more options for backing up and restoring the lxd file system if you configured lxd to use a file system below the top level zpool. I had lxd configured to use a pool directly, which made it difficult to send to a new zfs pool with the same directory structure since a destination pool had to exist to receive the stream. With the local pool set up as:
and the remote pool set up initially as:
I couldn't send to the remote to end up with the same directory structure as the local pool. I could only send to
But with lxd below the top pool like this, you could send the entire lxd file system to a pool on another volume and then mount the volume and import the pool to restore (provided you had the associated lxd database and other info).
https://github.com/lxc/lxd/blob/master/doc/storage-backends.md#zfs |
AceSlash
commented
Aug 16, 2016
|
I had to rescue a lxd host recently and to my surprise, I saw that /var/lib/lxd was (by default) not on the zfs dataset used by everything else. This is very dangerous: if you use zfs snapshot and send to backup tank/lxd (or whatever your pool name is), you won't have the lxd database and you'll have a lot of trouble to restore the host. Furthermore, this way of backup (taking everything, including the database), works in some case (when you want to restore the whole host), but doesn't in others common cases: like you want to import all the containers on an other host that already runs several containers. Currently, you can't do that easily without hacking the database. You also can't "lxc copy" to an other host and then send the incremental snapshots using lxd (you can with zfs). I think a simple way to export a container configuration to a sql file to be able to import it to an other host is necessary. With this, you can backup the container data with ZFS to a backup server and have a way to import the configuration. You could then restore a target container to an other lxd host. |
AceSlash
referenced this issue
Aug 16, 2016
Closed
How to restore a single container from backup zfs snapshot #2286
yoniy0
commented
May 5, 2017
|
@stgraber I'm still looking for a good LXD backup strategy. The documentation isn't quite complete, but can you comment on whether |
srkunze commentedNov 11, 2015
Building on top of #1302 what's would a sensible backup strategy look like?
I know that we need the LXD database in order to get the LXD daemon up and running again.
What about the containers themselves? Snapshots? Configs?
In other words: what's all necessary in order to recreate the complete container host in case of a hardware failure?