Skip to content

Instantly share code, notes, and snippets.

@trapier
Created November 16, 2015 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trapier/91c2887390a95c457bcb to your computer and use it in GitHub Desktop.
Save trapier/91c2887390a95c457bcb to your computer and use it in GitHub Desktop.
rsync based virsh migrate. minimal downtime and and avoids image bloating due to non-sparse copying.
#!/bin/bash
VM=$1
TARGET=$2
vm_path=/var/lib/libvirt/images/$VM.img
rsync -vS --progress $vm_path root@$TARGET:$vm_path && \
virsh migrate --live --suspend --persistent --undefinesource --verbose $VM qemu+ssh://$TARGET/system && \
rsync -vS --progress $vm_image root@$TARGET:$vm_path && \
virsh -c qemu+ssh://$TARGET/system resume $VM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment