How to migrate existing LXD instances between servers#

To move an instance from one LXD server to another, use the lxc move command:

lxc move [<source_remote>:]<source_instance_name> <target_remote>:[<target_instance_name>]

Note

When moving a container, you must stop it first. See Live migration for more information.

You don’t need to specify the source remote if it is your default remote, and you can leave out the target instance name if you want to use the same instance name. If you want to move the instance to a specific cluster member, specify it with the --target flag.

You can add the --mode flag to choose a transfer mode, depending on your network setup:

pull (default)

Instruct the target server to pull the respective instance.

push

Push the instance from the source server to the target server.

relay

Pull the instance from the source server to the local client, and then push it to the target server.

If you need to adapt the configuration for the instance to run on the target server, you can either specify the new configuration directly (using --config, --device, --storage or --target-project) or through profiles (using --no-profiles or --profile). See lxc move --help for all available flags.

Live migration#

Virtual machines can be moved to another server while they are running, thus without any downtime.

For containers, there is limited support for live migration using CRIU. However, because of extensive kernel dependencies, only very basic containers (non-systemd containers without a network device) can be migrated reliably. In most real-world scenarios, you should stop the container, move it over and then start it again.

If you want to use live migration for containers, you must enable CRIU on both the source and the target server. If you are using the snap, use the following commands to enable CRIU:

snap set lxd criu.enable=true
systemctl reload snap.lxd.daemon

Otherwise, make sure you have CRIU installed on both systems.