Clone LXD server

Hi @stgraber,

I need to clone my LXD server. The scenario I want is:

  • Create default storage from a disk image (mounted with /mnt/btrfs/lxd) and initialize containers on it
  • Full backup of /mnt/btrfs/lxd to a dedicated partition that is not a disk image as above (later also mounted to /mnt/btrfs/lxd)
  • Unmount the disk image and replace it with mount partition to /mnt/btrfs/lxd

As a result I can now start previous containers, list containers and images but I cannot create or delete containers.

How can I use it normally like before cloning.

Thanks!

The error messages I get are:

~ lxc image rm st-template                                                                  
Error: Image not found
~ lxc rm test
Error: Error deleting storage volume: Failed setting subvolume writable "/var/snap/lxd/common/lxd/storage-pools/default/containers/test": Failed to run: btrfs property set -ts /var/snap/lxd/common/lxd/storage-pools/default/containers/test ro false: ERROR: Could not get subvolume flags: Invalid argument

I suspect your full backup was done through rsync or the like and not using a tool which preserves the btrfs subvolumes.

1 Like

That’s right. I used rsync. So how should I do it without having to export/import containers, images and volumes

There are 3rd party tools that can replicate btrfs trees, so that may be an option.

Purely on the LXD level, ideally you’d have your target system also running LXD and would use lxc copy to transfer the instances.

1 Like

Thank you @stgraber