Simple KVM backups with tar and rsync
In this recipe, we are going to create a backup of a KVM instance using tar
and rsync
and store it on a remote server. This is the easiest way to backup a KVM instance. In the next few recipes, we are going to create snapshots and use them as a cold backup.
Getting ready
For this extremely simple recipe, we are going to need:
- A libvirt host with a running KVM instance, using an image file as its backing store
- The
tar
andrsync
Linux utilities - A remote server to transfer the backup
How to do it...
To back up a virtual machine using tar
and rsync
, perform the following steps:
- Create the backup directory and change to it:
root@kvm:~# mkdir backup_kvm1 && cd backup_kvm1 root@kvm:~/backup_kvm1#
- 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#
- Save the current instance configuration to disk:
root@kvm:~/backup_kvm1...