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.
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.