Live migration to another cluster (even from 3 to 5)

tapsa

Member
May 5, 2012
14
0
21
All old proxmox users know how frustrating it can be to migrate your enviroment from 3 to 4 or even to 5. Ad there is many many other reasons why you some times want migrate your vm's from cluster to another.

There is dirty hack for that.
- copy from your local machine authorized keys your public key to target enviroment.
- make directory path to your source machine /etc/pve/nodes/target/qemu-server/
- make directory path to your destination machine /etc/pve/nodes/source/qemu-server/

and then use that dirty totally unsafe script

#!/bin/sh
LOCALHOST="$(hostname)"
VMID=$1
REMOTEHOST=$2
/usr/bin/scp -r /etc/pve/nodes/${LOCALHOST}/qemu-server/${VMID}.conf root@${REMOTEHOST}:/etc/pve/nodes/${LOCALHOST}/qemu-server/
/usr/sbin/qm migrate ${VMID} ${REMOTEHOST} -online
/usr/bin/ssh root@${REMOTEHOST} mv /etc/pve/nodes/${LOCALHOST}/qemu-server/${VMID}.conf /etc/pve/qemu-server
/usr/bin/ssh -o 'BatchMode=yes' root@${REMOTEHOST} qm resume ${VMID} --skiplock
[ -d ./backup ] || mkdir ./backup
mv /etc/pve/nodes/${REMOTEHOST}/qemu-server/${VMID}.conf ./backup/


And use it with like migrate.sh id targethost

Yes this is hack and it will give errors to you. It is probably good idea to add more checks to that. Also note that in some cases that will leave migration lock to conf file and you need clean that.
Anyway this is just proof of concept that it is not quite hard to migrate vm from cluster to another and I think it is quite odd that there is no feature in proxmox it self for that.
 

Nkuean Kiriz

Member
Jan 27, 2018
1
0
21
32
Is this method safe for a 'production' host? I want to transfer from an old cluster to a new single node. But, the new node is currently on production.

What I did before was just copy the /etc/pve/qemu-server/<vmid>.conf from the previous node to the new one, since I'm running the images on a shared NFS storage, then just start and stop the VM. But this creates a 1-minute downtime. I want to 'live-migrate' all of my old VMs with 0 downtime.

I also don't want to add the new node to the cluster, then de-cluster the new node. I heard that it was such a risky thing to do (CMIIW)

Thanks before.
 
Last edited:
Jan 16, 2009
177
16
43
Hopefully they can implement, because it's not very operative to have to do this tasks by hand using backups.

In Proxmox v3 this option was available with the vzmigrate command. Unfortunately it was removed along with OpenVZ.
 

andy77

Active Member
Jul 6, 2016
245
8
43
39
Well the last message I read about that was on Jan 2021 so more then one year passed. Do you maybe have some update about their progress?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!