Switch to snap version - recover from disaster

Hello. I’ve suffered a system partition failure. I was able to rescue my /var/lib/lxd directory, and I have my main storage pool in another physical disk. After reading https://documentation.ubuntu.com/lxd/en/latest/backup/ my questions are:

  1. Could I switch distro (from Arch Linux to Open Suse Micro OS or Ubuntu, maybe Debian)?
  2. Could I restore to /var/snap/lxd/common/lxd (coming from /var/lib/lxd) I would prefer to use Snap from now on.

Could you give some advice/orientation in how to proceed?

What version of LXD was in /var/lib/lxd?

I think you would need to do something like this:

  1. Copy your old /var/lib/lxd to the new disk in the same location (maintaining permissions, owner etc).
  2. Install the snap package using snap install lxd --channel=5.0/stable to get the LTS version.
  3. Run sudo lxd.migrate

That should then detect /var/lib/lxd and convert it for you.

Hello! And thanks for your response.

lxd.migrate returns me

“error: Data migration is only supported on Ubuntu at this time”

I’m using Almalinux 9.2. Any other option to recover?

Hello again. I managed to surpass this error by changing os-release, but now when I do lxd.migrate I’m getting:

The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap <command> [<options>...]

Commonly used commands can be classified as follows:

Basics: find, info, install, remove, list
...more: refresh, revert, switch, disable, enable, create-cohort
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs
Permissions: connections, interface, connect, disconnect
Configuration: get, set, unset, wait
App Aliases: alias, aliases, unalias, prefer
Account: login, logout, whoami
Snapshots: saved, save, check-snapshot, restore, forget
Device: model, reboot, recovery
... Other: warnings, okay, known, ack, version
Development: download, pack, run, try

For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.

Please show your full command invocation steps?

Almalinux just installed, and then:

su
dnf install snapd
systemctl enable snapd --now
snap install lxd --channel=5.0/stable

returning:
2023-07-24T11:50:44+02:00 INFO Waiting for automatic snapd restart…
lxd (5.0/stable) 5.0.2-838e1b2 from Canonical✓ installed

then change os-release to

NAME=“Ubuntu”
VERSION=“20.04.1 LTS (Focal Fossa)”
ID=“ubuntu”
ID_LIKE=“debian”
VERSION_ID=“9.2”
PLATFORM_ID=“platform:el9”
PRETTY_NAME=“AlmaLinux 9.2 (Turquoise Kodkod)”
ANSI_COLOR=“0;34”
LOGO=“fedora-logo-icon”
CPE_NAME=“cpe:/o:almalinux:almalinux:9::baseos”
HOME_URL=“https://almalinux.org/
DOCUMENTATION_URL=“https://wiki.almalinux.org/
BUG_REPORT_URL=“https://bugs.almalinux.org/

ALMALINUX_MANTISBT_PROJECT=“AlmaLinux-9”
ALMALINUX_MANTISBT_PROJECT_VERSION=“9.2”
REDHAT_SUPPORT_PRODUCT=“AlmaLinux”
REDHAT_SUPPORT_PRODUCT_VERSION=“9.2”

and

lxd.migrate

And then I got the snap error.

EDIT: trying only “lxd init” gives me “error: unknown command “init”, see ‘snap help’” ¿?

EDIT2: ls -la in /var/lib/snapd/snap/bin

drwxr-xr-x. 2 root root 148 Jul 24 11:51 .
drwxr-xr-x. 6 root root  69 Jul 24 11:51 ..
lrwxrwxrwx. 1 root root   7 Jul 24 11:51 lxc -> lxd.lxc
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.benchmark -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.buginfo -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.check-kernel -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.lxc -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.lxc-to-lxd -> /usr/bin/snap
lrwxrwxrwx. 1 root root  13 Jul 24 11:51 lxd.migrate -> /usr/bin/snap

this is wrong, or not?

After uninstall and reinstall, changing os-release to the showed one, I’ve been able to run lxd.migrate, getting:

2023/07/24 13:21:35.673393 system_key.go:254: running from non-installed location /var/lib/snapd/snap/snapd/19457/usr/bin/snap: ignoring system-key
internal error, please report: running "lxd.migrate" failed: missing snap-confine: try updating your core/snapd package

Then I tried

snap install core
lxd.migrate

same result. What to do?

I’ve token another path: recreated profiles and file structure in my old server and did

lxd recover

After some struggling (see Error using lxd recover) I’ve been able to recover my old installation.

Now I’m facing some problems like no ip addresses in my containers (they were fixed ips, the dynamic ones are working)… let’s see what happens.

Anyway, it would be a good thing that lxd.migrate could work in all distros. At least if you are using Snap version of LXD.