Score:0

What is an appropriate backup strategy for LXD with BTRFS storage backends

ma flag

I'm about to re-configure my home server from scratch and am wondering what would be the best strategy to backup my LXD containers. Meanwhile I am running Ubuntu 20.04 LTS and have some services configured to run as LXD/LXC containers. For example:

  • container "cloudserv" running seafile
  • container "webservice" running nginx and MariaDB

These two containers are located on my SSD with btrfs filesystem. For data storage I am using an array of disks (also with BTRFS), where I have created another LXC storage pool with a storage volume which is the attached to the seafile container to hold all the data. The layout is something like this:

SSD

  • BTRFS Filsystem
    • Storage Pool "Default"
      • container "cloudserv"
      • container "webservice"
      • images

HDDs

  • BTRFS Filesystem
    • Storage Pool "DataPool1"
      • custom storage volume "seafile-data" --> attached to container "cloudserv"

By using BTRFS I was hoping to be able to make use of BTRFS snapshots and send and receive tools to easily transfer containers and storage volumes as subvolumes e.g. to a RasPi with a BTRFS volume attached. But reading e.g. LXD Manual or How to backup and restore LXD containers I have the impression that I always have to create a tarball to backup an instance which can then be transferred. This would imply that I actually loose some of BTRFS attractive features like being able to send/receive the subvolumes/snapshots and doing incremental backups of my LXC instances and data.

Do I miss anything? Can anybody give some hints for appropriate backup workflow for LXD/LXC with BTRFS?

Score:0
in flag

If you install LXD in your remote server and both servers use Btrfs, you can use the Optimized instance transfer like this:

lxc remote add mybtrfsremotebackupserver XXX
lxc snapshot mycontainer snap1
lxc copy mycontainer mybtrfsremotebackupserver: --verbose

And it will use btrf-send for the initial transfer of the container and all its snapshots.

Then you have a very convenient way of maintaining then container and it's snapshots only sending incremental changes using the option --refresh (LXD 3.7)

lxc copy --refresh mycontainer mybtrfsremotebackupserver: --verbose

But unfortunately it uses rsync, at least in LXD 4.0, so you will lose the btrfs-send optimization.

Check this issue for more info: Feature request: --snapshots-only flag for copy

Also, there is "Refresh support for custom volume copies" but I'm not sure if it uses the optimized path or if it could be useful for your objective. You can also check --optimized-storage in the lxc export

Regards

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.