Migrating between two Server

Hi @all,

I have two servers:
old - ubuntu 24.04
new - debian 12

I want to transfer my containers. There is a version difference in the incus package between the two systems (Ubuntu: 6.0.0 and Debian 6.0.3) so I can’t build a cluster.

There is not enough storage space on the old system to export the large containers.

Is there a way to export and send the data to the target server via ssh?
Or is there a way to specify a path so that I can use an external hard drive?

Thanks Frank

Just add the remote server as a remote and then do incus copy local:XYZ foo:

Just in case you haven’t done this before, here’s a primer. For the sake of this example I am assuming host ‘oldserver’ is reachable at 10.0.0.10, and I am calling the new server ‘new-server’

Instructions:
SSH into old server and issue a token:

incus config trust add new-server
Client newserver certificate add token:
eyJjbGllbnRfbmFtZSI6Im5ld3NlcnZlciIsImZpbmdlcnByaW50IjoiNTBmODgyYzE0MzllODMxNDE0YmI1MTZhZjYyZGM2NWY5NzdjZjVjZDI4MzVhNjg2YTczMjRlMWY4NjhjMDYzYyIsImFkZHJlc3NlcyI6WyIxMC4yMzEuMjUuMjQ6ODQ0MyIsIjEwLjIzMS4yNS4xNDo4NDQzIiwiMTAuMjMxLjI1LjE2Mjo4NDQzIiwiMTcyLjE2LjUwLjE0Ojg0NDMiLCIxNzIuMTYuNTAuMTAzOjg0NDMiLCIxMC4yMy4xNi4xOjg0NDMiXSwic2VjcmV0IjoiOWVjY2EwZGVhMjZjYmI3ZjQ2ZTVjZDg4MGQ5MDI5YmRmZWE5MjdkM2JjZjc0NTBlZDhkOWExNjgyNzU3NTc2NyIsImV4cGlyZXNfYXQiOiIwMDAxLTAxLTAxVDAwOjAwOjAwWiJ9

Copy the long token string (every character). Now ssh into new server as usual and issue the following command, and then follow the prompts, pasting the long token blob above into the terminal for the requested ‘trust token’:

incus remote add oldserver 10.0.0.10
Certificate fingerprint: 50f882c1439e831414bb516af62dc65f977cf5cd2835a686a7324e1f868c063c
ok (y/n/[fingerprint])? yes
Trust token for oldserver: eyJjbGllbnRfbmFtZSI6Im5ld3NlcnZlciIsImZpbmdlcnByaW50IjoiNTBmODgyYzE0MzllODMxNDE0YmI1MTZhZjYyZGM2NWY5NzdjZjVjZDI4MzVhNjg2YTczMjRlMWY4NjhjMDYzYyIsImFkZHJlc3NlcyI6WyIxMC4yMzEuMjUuMjQ6ODQ0MyIsIjEwLjIzMS4yNS4xNDo4NDQzIiwiMTAuMjMxLjI1LjE2Mjo4NDQzIiwiMTcyLjE2LjUwLjE0Ojg0NDMiLCIxNzIuMTYuNTAuMTAzOjg0NDMiLCIxMC4yMy4xNi4xOjg0NDMiXSwic2VjcmV0IjoiZTIxN2E3MDA4NmRiY2M5MDQyYjUwZTUzMTg2Y2I5OWQyN2I1MGQ4NTM3MjBhM2IzMTA2N2YwMjE2MDdjMWU1NCIsImV4cGlyZXNfYXQiOiIwMDAxLTAxLTAxVDAwOjAwOjAwWiJ9
Client certificate now trusted by server: oldserver
root@new-server:~# 

Now you have a connection from new server to old server (not the other way round). So you can list and copy instances, profiles etc. from the oldserver by issuing commands at the new-server:

root@new-server:~# incus list oldserver:      #  <-- make sure there's a colon after the name

+-------------------------+---------+-----------------------+------+-----------------+-----------+
|          NAME           |  STATE  |         IPV4          | IPV6 |      TYPE       | SNAPSHOTS |
+-------------------------+---------+-----------------------+------+-----------------+-----------+
| Instance-Name           | STOPPED |                       |      | VIRTUAL-MACHINE | 11        |
+-------------------------+---------+-----------------------+------+-----------------+-----------+

And then pull copies of what you need, e.g. pull a copy of an instance named ‘daily-status’ from the oldserver and assign it the same name at the new server:

root@new-server:~# incus copy oldserver:daily-status daily-status
Transferring instance: daily-status: 368.08MB (18.36MB/s)
root@new-server:~#

Beware that an instance on the old server has a profile, and it will expect a profile with the same name on the new server. So if you need to, pull copies of profiles over first and maybe modify them if the new-server is configured differently from the old one. Containers, vms, profiles - everything can be copied over. For more detail see the docs.

V/R

Andrew

3 Likes

Many thanks, works like a charm.
In the last few days I have exported all my containers to make space. Unfortunately, importing a 70G Gitlab container is a pain and takes almost a day. If only I had known that beforehand :slight_smile:

Thanks Frank

I feel for you. If it helps you feel better, I send half-terabyte ones overseas sometimes LOL.

Glad it worked.

Here’s a script I use to add remotes:

#!/usr/bin/env bash

# incus_addremote
# Adds a remote host to a local incus server

# Check for a single command line argument
if [ "$#" -ne 1 ]; then
    echo "Usage: incus_addremote <remote_host>"
    exit 1
fi

HOST=$1

# Test to see if host is reachable
ping -c 1 -q $HOST > /dev/null 2>&1

# Check the exit status of the ping command
if [ $? -ne 0 ]; then
    echo "Error: Unable to reach $HOST"
    exit 1
fi

TRUST=$(ssh $HOST incus config trust add $HOSTNAME)
TOKEN=$(echo $TRUST | cut -f 6 -d ' ')

incus remote add $HOST --token "$TOKEN"
1 Like