Proper migration from old LXC to Incus

Hello,

we are running LXC on a older Ubuntu machine and we want to migrate away from it due to hw issues. These issues seems to be connected to heavy I/O and manifest by the machine completely freezing. We have only network access to the box.

Anyway, we thought we migrate to Incus. We export the containers on the old machine like this:

lxc export --instance-only container container.tgz

We copy this export to a new Debian 12 machine with Incus 6.0 from backports. We then try to import the file to Incus like this:

incus import -s incus_storage_pool container.tgz container

Here we run into problems, because Incus complains about missing snapshots:

Error: Failed importing backup: Failed checking snapshots: Snapshot count in backup config (1) and storage device (0) are different: Backup snapshots mismatch

Bummer… But OK, we unpack the archive, edit the backup/container/backup.yaml, remove the whole snapshot: section and replace it with snapshot: [] and repack the archive into a file container_fixed.tgz

Another try at import and this time Incus complains like this:

Importing instance: 100% (2.37GB/s)Error: Backup is missing at "backup/index.yaml"

This file however exists in the archive… Seems like a dead end. Is there a proper clean way how to export from LXC over network and import into Incus ? Thanks for any hints.

BTW we dont see the “incus” package on the old machine available. Should we try install incus there, migrate everything there to Incus and only then transfer to the new box ? Thx !

Welcome!

I think you are migrating from LXD (not LXC) towards Incus.
Since the commands you are using are lxc export, then the old computer has LXD.

There’s a tool, lxd-to-incus (not incus-migrate), than can help a lot in the migration.
What’s the LXD version you are currently running? There are specific versions of LXD that can be migrated easily, other versions no so much due to differences in the database.

Hello Simos, thansk for your reply. These are the versions:

root@server ~ # dpkg -la|grep -e lxd -e lxc
rc  liblxc-common                           1:4.0.2-0ubuntu1                            amd64        Linux Containers userspace tools (common tools)
rc  lxcfs                                   4.0.3-0ubuntu1                              amd64        FUSE based filesystem for LXC
rc  lxd                                     1:0.10                                      all          Transitional package - lxd -> snap (lxd)
root@server ~ # snap list |grep lx
lxd      4.0.10-d342340  32662  4.0/stable/�   canonical**    -

What we call LXC and LXD are different and separate.
They do depend on liblxc though, but when you create instances with either of the two, those instances cannot be managed by the other. Many sites are confused by this, even those that are found on top of the search results.

Let’s check first for LXC. The commands look like lxc-start, lxc-ls.
Run the following. The first will show if you have LXC instances. The second will easily show the version of LXC that is running.

sudo lxc-ls
sudo lxc-ls --version

Now for LXD. The commands start with lxc, which is very confusing.
Run the following to show what instances are there, and also to show the versions of both the server and the client.

lxc list
lxc version

When you setup Incus, the commands start with incus. With Incus you would run the following to get the list of instances and check the version.

incus list
incus version

Alright, thats quite confusing. So yes, we are running LXD in this version:

lxc version
Client version: 4.0.10
Server version: 4.0.10

Okay, so you are going to be migrating from LXD to Incus, and Incus will be running on a new separate server.

I do not know how many instances (containers/virtual machines) you have in the old installation. If they are just a few, you can sort out the snapshots issue (there are several threads on that on this discussion forum), and migrate manually (export/import).

If there are too many instances in the old installation, you can migrate (move) the old installation to the new server, then use on the new server the lxd-to-incus tool to migrate from within the same server the whole installation from the old to Incus.

Which direction do you think you will take?

Can you point me to a few threads re: snapshots issue plz ?

LXD 4.0.x has an issue with its backups missing metadata on snapshots.
It may be a good idea to update the source system to LXD 5.0.x then exporting and importing should work correctly.

That’s assuming you don’t instead go with the lxd-to-incus mechanism which should be able to handle LXD 4.0 to Incus 6.x in one shot.

I exported only the bare instances sans snapshots on the old machine. The reason is that when exporting the backups with snapshots, the machine freezes. So i dont actually want any snapshot metadata in the exports. I solved that by hand, by removing the metadata from the exported file. That helped with this issue, but led to another issue.

I can try to upgrade LXD on the old mchine to a later version. Maybe its worth a try. However i cant use lxd-to-incus because this tool doesnt support migration between two separate machines.

BTW i see that we are on channel 4.0/stable/ubuntu-22.04. Is it safe to switch to a channel like this: 5.0/stable: ? Will snap handle the upgrade smoothly ?

I’ve not been involved with that in a couple of years now, but back then, yeah, switching from 4.0 to 5.0 was pretty routine and reliable.

I believe that’s done with snap refresh lxd --channel=5.0