Here’s a script that removes snapshots from lxd configuration. Requires yq.
for CT in $(zfs list -r -d 1 -H -o name tank/containers | tail -n +2 | rev | cut -d/ -f 1 | rev); do
zfs set mountpoint=/var/lib/lxd/storage-pools/tank/containers/$CT tank/containers/$CT && zfs mount tank/containers/$CT
cp /var/lib/lxd/storage-pools/tank/containers/$CT/backup.yaml /var/lib/lxd/storage-pools/tank/containers/$CT/backup.yaml-rmsnaps
yq -i '.snapshots=' /var/lib/lxd/storage-pools/tank/containers/$CT/backup.yaml
After doing this, I had to remove any external disks (mounted paths) from containers because lxd-snap doesn’t allow access to host disks, and I was finally able to complete the recovery.
Overall the process was very windows-like,
lxd recover being only an interactive utility, I think I typed the same things around 20 times just to see the next error.
Typing it in void probably, but here’s my wishlist:
- When doing do-release-upgrade, when lxd upgrades itself to snap, it would be nice if it imported the containers
lxd recover should support command-line options, so the user can run another retry without typing the same over and over again interactively
lxd recover should ask about zfs pool name. Having to guess I have to type an option named
zfs.pool_name=tank after answering
tank to the first 3 questions was puzzling.
- There should be an option to proceed with an import in presence of failed checks, such as missing snapshots or inaccessible volumes. I’d much rather have the containers imported and 1 or 2 containers not starting because of the problems, than have nothing imported because one container failed.
- I miss the functionality of
lxd import - just importing one container. It gave so much flexibility. I’m still on lxd 3.0 on my production hosts and am using
lxd import as a simple failover mechanism. It seems there’s no way to do it with lxd 4 or 5.
I still have to figure how to mount the shared host directories - the trick with prepending snap hostfs path didn’t work. But at least I have majority of containers working now.