Virtkick Docs

Documentation and information to Virtkick your business

How to Restore a Live Backup on a KVM Virtual Machine

Arguably the most important part of maintaining backups is the ability to restore from a backup if the need arises. We previously added a guide explanining how you can take live backups of your KVM virtual machines, now we will walk you through the process of restoring such a backup.

1. Move backup files, prepare for restoration

The first step in restoring a backup is to ensure that the backups are present on the hypervisors where the restoration is to occur. Be sure you have the qcow2 disk image as well as the XML definition for this machine.

Once you have both of these things, you'll need to first edit the XML file to use the qcow2 image you have created as a backup.

Look for this section in the XML file:

  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2' cache='none'/>
    <source file='/home/virtkick/hdd/1_c72backuptest_d10af10c-cd41-4220-a175-0476eb4918c9.qcow2'/> <--- You will be editing this line
    <backingStore type='file' index='1'>
      <format type='raw'/>
      <source file='/home/virtkick/template/ubuntu-1604-lts_template_27042016-2.qcow2'/>
  <target dev='vda' bus='virtio'/>
  <alias name='virtio-disk0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>

Change the line designated above to reflect the full path to the disk image you want to use on this restored machine. Additionally, change the value between the <name> tags to reflect a unique name. Two machines cannot exist on the same hypervisor with the same time.

After these changes have been made you can move on to the next step.

2. Perform the restoration

The last step of this process is to actually restore the machine. You do this by creating a new virtual machine with the XML file you just edited. You can do this using the following command:

virsh -c qemu:///system define /path/to/your/xml/file.xml

You can then confirm the machine is present by running:

virsh -c qemu:///system list --all

Make sure your new machine is listed among the output of that command. If it is, you can move on.

Now you will just need to start the machine, you can do this by executing:

virsh -c qemu:///system start MACHINE_NAME

Substitute the MACHINE_NAME with the name you chose in the previous step.

Your machine should now be running with the data from your backup.

Have any problems? Let us know - we are happy to help!

Back to the list ยป

Joe Pettit
Developer @ Virtkick
comments powered by Disqus