Restore containers from read only btrfs storage volume

I’m LXD 3.0 snap with 2 storage volumes on a single host. One of the storage volumes is BTRFS and has gone bad and can now only be mounted read only without locking up.

What are my options for restoring these containers? How can I transfer them to the other storage volume?

These containers take up about 2TB in data and the other storage is only a small SSD but I would still like to transfer some for the containers to it.

All the containers have a backup.yaml so I’m guessing I just need to copy them somewhere, redo the BTRFS volume, move the containers back and then import them?

Yeah, you should be able to use btrfs send/receive to copy those subvolumes to your other disk. If you have another spare system nearby with a bunch of storage, you could also send/receive the entire content over the network before resetting your btrfs filesystem.

Do i need to copy the containers, snapshots, images, custom subvolumes or just the containers/blah subvolumes of the containers I want to keep?

The snapshots aren’t important to me.

lxd import won’t let you re-import the images and you have a copy of them already as tarballs in /var/lib/lxd/images so those should be fine.

For the containers, you’d want /var/lib/lxd/storage-pools/POOLNAME/containers/NAME for every container you care about. Putting that back in place later should make re-importing with lxd import work fine.

For custom volumes, copy the subvol or content from /var/lib/lxd/storage-pools/POOLNAME/custom/NAME and to restore them, you’ll just create a new custom volume with the same name and swap that for the backup you made.