Backup with LXD 4.7 - LXC storage volume export


I am using UrBackup as a current backup solution for the home.
I have been running into an issue where it is unable to backup my current Storage Pool (Located: /var/snap/lxd/common/lxd/disks/default.img) which is using ZFS.
This of course makes sense as it is technically being used and such.

After looking at the latest news announced about LXD 4.7 - I saw we now have a new backup export command Lxc storage volume export

My questions are:

  1. If I was to use this command would this create a backup of everything I would need to be back up and running from a SSD failure? (If I needed to install the LXD Snap on a new system, transfer over the backup and import it)

  2. If I require other additional commands, in what order should I run them?

  3. When using the storage volume export - will there be an outage or will it take a snapshot and use that to create the tar backup?

Thank you in advance and amazing work! Love these containers!


The lxc storage volume export command exports a single volume on a storage pool to a tarball.

This tarball can then be re-imported into another LXD system (or a rebuilt system) using the equivalent lxc storage volume import.

However the storage pool needs to exist before it can be re-imported, so this would need to be re-created before the volume(s) can be re-imported.

At the current time the backup process does not stop or unmount the volume, and it does not take a snapshot, so if the volume is being written to it would be an inconsistent backup.

This maybe something that we want to change in the future. @stgraber do you have any comment with regard to that?

It’d probably make sense to create a temporary snapshot for the main volume when exporting it (for zfs and btrfs) or require freezing it at least (for dir, lvm and ceph)

That’s for non-optimized exports, optimized exports on btrfs, zfs and ceph effectively already use a snapshot

Hi Thomas and Stéphane,

Thank you for the clarification. So I should be stopping all containers and then perform a lxc storage volume export

I do agree there should be a freezing process. Although is there a way to do an “Optimized export” at this time?

Additionally just to be sure, after exporting the storage pool, will I need to import each lxc container to contain a more “Complete” backup?

I am just looking at how this would fit into a backup solution so I can create the necessary cron jobs. As UrBackup uses the Dattobd backup module, it would make sense now why the backups were having issues. It was not issuing a freeze command or a stop command before proceeding, creating inconsistencies.

To be clear, the custom volume export feature does not export a whole “storage pool”, but only a custom volume on a storage pool. The storage pool itself can also house container and VM storage volumes that are exported differently (using lxc export command).

You can do an optimised export of your custom volume if it is stored on a storage pool that supports optimised exports (btrfs and zfs). These optimized backups are specific to the storage driver used which means the backups can only be imported back to the same type of pool.


Create and backup (optimised) a custom volume:

lxc storage volume create zfs vol1
lxc storage volume export zfs vol1 /home/user/vol1.tar.gz --optimized-storage

Create and backup (optimised) container:

lxc init images:ubuntu/focal c1 -s zfs
lxc export c1 /home/user/c1.tar.gz --optimized-storage