Migrating ZFS backed VMs between Proxmox Clusters

Migrating VMs inside a proxmox cluster is easy. But what to do when you need to migrate a VM to another proxmox cluster? With a bit of command line, the rest is easy as long as you’re using ZFS. Even for the largest VMs the amount of down time required is mimimal.

####################################
#Example scenario #
####################################
#Source cluster host: PVEA
#Source cluster VM ID: 199 (WARNING! make sure your IDs don't overlap on clusters otherwise you may overwrite your data)
#Destination cluster host PVEB

#on PVEA take snapshot and call it "migrate"

#confirm you're migrating the right one
PVEA>zfs list


#send data. This command may run very long time, but it's ok because the source VM keeps running
PVEA>zfs send rpool/data/vm-199-disk-0@migrate  | ssh PVEB zfs recv rpool/data/vm-199-disk-0

#when it finishes shutdown VM ID 199
#on PVEA take snapshot and call it "migrate2"

#send incremental data
PVEA>zfs send -i rpool/data/vm-199-disk-0@migrate rpool/data/vm-199-disk-0@migrate2 | ssh PVEB zfs recv rpool/data/vm-199-disk-0

#check that you got the data (this transfer should be super fast)
PVEB>zfs list -t snapshot

#send config over
PVEA>scp 199.conf PVEB:/etc/pve/qemu-server/199.conf 

#on PVEB start VM ID 199 (and optionaly delete snapshots)
#done!

Leave a Reply

Your email address will not be published. Required fields are marked *