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


I am trying to figure out how to properly backup my LXD containers with a ZFS backend.
Should I use snapshots or do I have to use images ? How can I create new containers from a file containing a snapshot ?

Here is what I gathered for the two approaches:

Using snapshots

I feels natural to want to use the ZFS snapshots, but how would I to restore them in LXD ?

  • lxc snapshot my-container my-backup
  • lxc config show my-container > my-container_my-backup.lxd.config
  • zfs send zfspool/containers/my-container@snapshot-my-backup > my-container_my-backup.lxd.zfs


  • Create the container from the config somehow ?
  • zfs receive zfspool/containers/my-container2@my-backup < my-container_my-backup.lxd.zfs
  • lxc restore my-container2 my-backup

Using images

Or should I generate images and export them ? It feels a bit weird to generate images when all I want is to create a backup - I want to restore it in the future, not create new ‘instances’ of it.

  • lxc publish my-container --alias my-backup-image
  • lxc image export my-backup-image .


  • lxc launch my-image my-container2

Thanks enlightening me on this !


Bumping it. I am also looking for the right approach for doing a backup and restore. I tried the 2nd approach (using images) but I’d rather use the recently introduced snapshot.expiry, snapshot.schedule, etc. and let lxd do the management part.

@hoh Which approach did you end up using?

have an eye on this