O'Reilly logo

KVM Virtualization Cookbook by Konstantin Ivanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To back up a virtual machine using tar and rsync, perform the following steps:

  1. Create the backup directory and change to it:
root@kvm:~# mkdir backup_kvm1 && cd backup_kvm1root@kvm:~/backup_kvm1#
  1. Find the location of the image file of the KVM guest:
root@kvm:~/backup_kvm1# virsh dumpxml kvm1 | grep "source file" <source file='/var/lib/libvirt/images/kvm1.img'/>root@kvm:~/backup_kvm1#
  1. Save the current instance configuration to disk:
root@kvm:~/backup_kvm1# virsh dumpxml kvm1 > kvm1.xmlroot@kvm:~/backup_kvm1#
  1. Stop the KVM guest and copy the image file to the backup directory:
root@kvm:~/backup_kvm1# virsh destroy kvm1Domain kvm1 destroyedroot@kvm:~/backup_kvm1# cp /var/lib/libvirt/images/kvm1.img .root@kvm:~/backup_kvm1# ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required