LXD on LVM - best practice for disaster recovery


(Vic) #1

Although it’s officially supported, there really isn’t much documentation around for LXD on LVM, and many LXD built-in commands don’t seem to work with LVM as a storage backend. Currently, I’m trying to figure out how to best proceed to backup and, in the event of a disaster, restore my containers.

I understand there probably not the one solution for this. My primary goal is to minimize time (and complexity) to restore.

The official documentation says that in order to do a full backup, the entirety of /var/lib/lxd should be backed up, as well as the LVM volume group holding the container volumes. I’m trying to make sense of that statement.

Clearly, the content of /var/lib/lxd changes considerably depending on whether the containers are started or not. If they are started, their volumes will be mounted to /var/lib/lxd/storage-pools. If you were to back up that folder but also the whole volumes, you’d back up the same twice. So what is exactly meant here? Really back up all the data in /var/lib/lxd and just back up the meta data for the LVM volume group, or backup /var/lib/lxd without the mounted storage-pools and make a full backup of the LVM groups and volumes?

As a follow up to that question, let’s assume for a second that I cannot recreate the exact same PV/VG, I lost or discarded the meta data to do so. Instead, I switch to a new machine, set up a new PV/VG (e.g. on a bigger and better disk) but I recreate a thin pool with the same name and recreate the same volumes using backups. How would I tell LXD where to find the storage for its containers?

And any other advice you can share on this topic would be highly appreciated.


#2

“Also, if you use LVM across hard drives, you may lose all your data when only one drive fails.”
(Source: https://askubuntu.com/questions/3596/what-is-lvm-and-what-is-it-used-for, - last third).
Just a question first: Why don’t you using zfs ?
I assume you have to use LVM, right?
Which OS are you using ?
Which version of LXD ?
Do you know there is a snap LXD - THE current version - out there as well?

Before we can dive into deeper have you seen this: Backing up containers and this Backup the container and install it on another server?

What about https://github.com/zfsonlinux/zfs/wiki/Ubuntu-18.04-Root-on-ZFS or
https://github.com/zfsonlinux/zfs/wiki/Ubuntu-16.04-Root-on-ZFS


How to properly backup+restore LXD containers with ZFS backend?