Best way for container migration (miss you, lxd import)

A few months ago, I was looking for a best way to migrate LXD containers between nodes. Low downtime was the main criterion.
Live migration,based on documentation, can only be done through СRIU, but this technology works very bad.
Therefore, the following method was chosen:

  • create an empty LXD container on the destination node;
  • rsync container files from source node to destination (without turning off the container);
  • import container on the destination server with lxd import (in order to import container’s configs);
  • stop container on source node;
  • one more rsync of container files;
  • start container on destination node.

This scheme worked fine, but in LXD 4.17, the lxd import command was removed, and the lxd recover added instead, but it doesn’t have a similar non-interactive functionality.

Tell me, please, is there any other method for exporting and then importing container configs?
Or are there other ways to migrate containers with little downtime?

Thanks in advance.

1 Like

I’d probably use lxd-p2c to transfer the container’s filesystem directly into a new container on the target LXD.

If you have a Github account, you can find static binary builds at Actions · lxc/lxd · GitHub
The current most recent is:

@stgraber Thank you! I’ll try to use this method.

@stgraber I read the documentation about lxd-p2c, as I understand it, this application will help us create a container on a destination server and synchronize files, but it does not solve the issue of transferring configs. With lxd-p2c we need to set container’s config params manually.

Is there any possibility to export only config of LXD container (without files) on one server and import this config to LXD container on another server?

If you’re copy LXD to LXD, why aren’t you just using lxc copy?

You can run it on running containers with --stateless and can even run --refresh to update the remote copy after you’ve done an initial pass, so for minimal downtime, something like:

lxc copy foo target:foo --stateless
lxc stop foo
lxc copy foo target:foo --refresh
lxc start target:foo
1 Like

It looks like this is exactly what I was looking for.
Thanks, I’ll try.


It works! :slight_smile:
Thank you!