Copy LXD container to another host

Hi! I have a two hardware hosts (svr1, svr2)
svr1(192.168.20.220, diz) - old host with ubuntu16.04 and have a many containers (LXD version 2.0.11)
svr2(192.168.20.75, blade) - new host with ubuntu 18.04 (LXD version 3.0.2)
I create br0 bridge on the srv2 and manually assign new network profile to any new containers created on this host (svr2), i don’t create default bridge in “lxd init”.

I want copy a few containers from svr1 to svr2

i taking a snapshot container named “upsource” on svr1 and copying

sudo lxc copy upsource/snap0 blade:upsource

i see, on the svr2 show up container named “upsource”, after that a receive error:

error: Failed container creation:

i don’t have firewall
i guess network 172.17, 172.18 - it’s a docker networks
how to copy container without network settings? it is possible? or what i doing wrong?

Exit status 12 suggests a rsync feature mismatch which would be explained by the difference in rsync arguments between the two versions.

It’s something we’ve since resolved and that will be solved in 3.0.3.

Until then, one trick that may work is to force the source server to pass the missing rsync option by wrapping rsync.

You could do this by writing:

#!/bin/sh
exec /usr/bin/rsync "$@" --xattrs

to /usr/local/bin/rsync, then make it executable with chmod +x /usr/local/bin/rsync and attempt the migration again.

Note that you’ll want to remove this file once done with the transfers as it’d otherwise make every rsync call on the system use that --xattrs option which is unlikely to be desired.

1 Like

it’s works!! Thank you very much!

Hi @stgraber , im still having this issue but in my case it’s not a exit 12 error, I can’t seem to find any logs on the host or remote for more details any thoughts would be greatly appreciated.

1- confirmed that the remote host was added into local (qwerty) remote list
2- confirmed that remote host is listening on port 8443, and is open for network access

remote:
ubuntu@odin:/var/log$ lxd --version
3.8
ubuntu@odin:/var/log$ lxc --version
3.8

local:
ubuntu@qwerty:~$ lxd --version
3.8
ubuntu@qwerty:~$ lxc --version
3.8

remote list:
ubuntu@qwerty:~$ lxc remote list
±----------------±-----------------------------------------±--------------±----------±-------±-------+
| NAME | URL | PROTOCOL | AUTH TYPE | PUBLIC | STATIC |
±----------------±-----------------------------------------±--------------±----------±-------±-------+
| images | asdfsadf | simplestreams | | YES | NO |
±----------------±-----------------------------------------±--------------±----------±-------±-------+
| local (default) | unix:// | lxd | tls | NO | YES |
±----------------±-----------------------------------------±--------------±----------±-------±-------+
| odin | https://xxx:8443 | lxd | tls | NO | NO |
±----------------±-----------------------------------------±--------------±----------±-------±-------+

network test
ubuntu@qwerty:~$ nc -vz xxx 8443
Connection to xxx 8443 port [tcp/*] succeeded!

copy statement:
ubuntu@qwerty:~$ lxc copy u1/current-snap odin:u1-current
Error: Failed container creation:
- https://192.168.178.21:8443: Error transferring container data: Unable to connect to: 192.168.178.21:8443
- https://172.17.0.1:8443: Error transferring container data: Unable to connect to: 172.17.0.1:8443
- https://10.236.74.1:8443: Error transferring container data: Unable to connect to: 10.236.74.1:8443
- https://[fd42:4cee:6c8f:8a41::1]:8443: Error transferring container data: Unable to connect to: [fd42:4cee:6c8f:8a41::1]:8443

Looks like a network path issue when the target server connects to the source one.

You may want to try with --mode=relay

1 Like

@stgraber – that did the trick! Many many thanks!

THANK YOU Stéphane Graber - I found this as I was searching for the same error, and the --mode=relay fixed it for me too! :-))

Hi,
I am using LXC/LXD 3.19 (installed using snap) on Ubuntu 18.04 and facing the similar issue while trying to migrate a running container (Error transferring container data: Rsync receive failed: /tmp/lxd_restore_228268594/: [exit status 12] () ). The above mentioned solution is not working in my case. zfs file system is used to create containers. Can you please provide a better stable solution?

What version are you trying to migrate from/to?

Thanks for prompt reply. I am using LXC/LXD 3.19 and rsync version 3.1.2 protocol version 31
on both, source and destination. I am just trying to migrate a running container (Ubuntu 18.04). Linux kernel version is 4.15.0-74-generic (default kernel version with ubuntu 18.04).

What is the command you are running the migrate the container?

Also are you running in a cluster or do you have a remote setup,if so, can you show me the remote IPs/hostnames you have configured.

Finally, do you have access to the lxd syslog messages when the transfer fails?

Command used to migrate containers:

lxc move source:container_name destination:container_name.

I am not ruuning in a cluster. I am just using two Virtual Machines to host containers. I used bridge of the host machine (VM) to assign IP to containers (10.129.x.y), not used lxdbr0. Currently, i don’t have access to lxd syslog messages but i can get that. Can you just please tell me the path or location of lxd syslog messages?

Could you provide output of please:

 lxc remote list

And where are you running the lxc move command from, is it on one of the LXD VMs or another machine?

Output of lxc remote list:
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| NAME | URL | PROTOCOL | AUTH TYPE | PUBLIC | STATIC |
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| images | https://images.linuxcontainers.org | simplestreams | none | YES | NO |
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| local (default) | unix:// | lxd | file access | NO | YES |
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| lxd2 | https://10.129.2.38:8443 | lxd | tls | NO | NO |
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| ubuntu | https://cloud-images.ubuntu.com/releases | simplestreams | none | YES | YES |
±----------------±-----------------------------------------±--------------±------------±-------±-------+
| ubuntu-daily | https://cloud-images.ubuntu.com/daily | simplestreams | none | YES | YES |
±----------------±-----------------------------------------±--------------±------------±-------±-------+

I am running the command on source VM.

Thanks.

So the command you sent earlier:

lxc move source:container_name destination:container_name

This doesn’t look quite right as there isn’t a remote called source nor a remote called destination.

Can you paste the exact command you run please.

Exact command used: sudo lxc move local:cont1 lxd2:cont1

Thanks, so I just tried this locally between machines running 3.19 snap and zfs and it worked OK.

I wonder if this is a communication issue are you able to show the output of netstat -tlpn | grep 8443 on both machines please.

Output on source: tcp6 0 0 :::8443 :::* LISTEN 8534/lxd
Output on destination: tcp6 0 0 :::8443 :::* LISTEN 6291/lxd

Out of interest, do you get the same error doing it the other way, i.e running it on the destination?