Virtkick Docs

Documentation and information to Virtkick your business

How to Restore Offline/Incremental Backups on your KVM Virtual Machine

So you have incremental backups - what how do you use them? This guide will walk you through the process of restoring your incremental backups.

Looking to create incremental backups? Take a look at our guide!

1. Preparation

First, you will need to identify which backup is to be used in the restoration process. You can do this using the following command:

virsh -c qemu:///system snapshot-list YOUR_MACHINE_NAME

Be sure to substitute YOUR_MACHINE_NAME with the name of the machine to be modified.

You should see output similar to this:

Name                 Creation Time             State
------------------------------------------------------------
backup1              2016-05-23 06:47:45 -0400 shutoff
backup2              2016-05-23 06:49:02 -0400 shutoff
backup3              2016-05-23 07:32:37 -0400 shutoff

Note the name of the backup you plan to use and then move on.

2. Perform the restoration

With this information you can begin the restoration process. To do this, shut down your virtual machine using the following command:

virsh -c qemu:///system shutdown YOUR_MACHINE_NAME

Next, edit your virtual machines definition using the command below:

virsh -c qemu:///system edit YOUR_MACHINE_NAME

After executing this you will see the XML definition for your virtual machine, look for lines similar to what is shown below:

  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2' cache='none'/>
    <source file='/home/virtkick/hdd/1_testbackup2_fb7715a2-1607-40c8-bc33-d31b3cd20489.backup3'/> <--- You need to edit this line
    <target dev='vda' bus='virtio'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </disk>

Edit the line highlighted above, replace the existing path to reference the backup you want to restore from. For example, if you want to use backup2 replace the line above like so:

  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2' cache='none'/>
    <source file='/home/virtkick/hdd/1_testbackup2_fb7715a2-1607-40c8-bc33-d31b3cd20489.backup2'/>
    <target dev='vda' bus='virtio'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
  </disk>

Please note, if you revert to a previous backup and start you virtual machine all backups OLDER than the restored backup will no longer be valid. Be sure you are okay with this!

If you are okay with the above information, you can start your virtual machine using the following command:

virsh -c qemu:///system start YOUR_MACHINE_NAME

3. Restore incremental backups on a different hypervisor (Optional)

You may need to restore your incremental backups on a hypervisor other than the one where the backups were created. To do this you need the XML definition for the domain in question. You can obtain this using the virsh command dumpxml like so:

virsh -c qemu:///system dumpxml YOUR_MACHINE_NAME > /path/where/you/want/the/xml/file.xml

Move this file to the hypervisor where the restoration is to happen. Edit the XML file just like we did in step two, update the source file= line to reflect the path to the backup you want to use. Afterwords, you will need to define the machine in addition to starting it.

You can define the machine using the following command:

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

Finally you can start the machine:

virsh -c qemu:///system start YOUR_MACHINE_NAME

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

Back to the list ยป

avatar
Joe Pettit
Developer @ Virtkick
comments powered by Disqus