Unable to access lxd snap after resore from old backup

I have zfs on root system which was upgraded from ubuntu 20.04 to ubuntu 20.10

I wanted to remove old snapshots. I used the -R option as a result I removed the /var/snap pool. I do not have a backup for 20.10, but I used the backup of /var/snap from 20.04 to restore. Now all my snaps are broken. Most importantly the lxd snap.

Snap refresh lxd:
snap “lxd” has no updates available

When I try to install and old version
snap refresh --channel=4.6/stable lxd I get:

error: cannot perform the following tasks:

  • Setup snap “lxd” (17738) security profiles (cannot find installed snap “lxd” at revision 18137: missing file /snap/lxd/18137/meta/snap.yaml)
  • Start snap “lxd” (17738) services ([start snap.lxd.activate.service] failed with exit status 1: Job for snap.lxd.activate.service failed because the control process exited with error code.

Is there any way to to restore the lxd snap

It should definitely be possible to recover from this. I think the easiest may be to:

  • Move /var/snap/lxd/common/lxd somewhere safe
  • Completely remove the LXD snap
  • Reboot the system to make sure things are clean
  • Install the LXD snap, this should behave like a completely clean LXD
  • snap stop lxd
  • Delete /var/snap/lxd/common/lxd and move back the one you saved earlier
  • snap start lxd