Recover a virtual machine

To perform disaster recovery of a virtual machine (VM), you can restore it from a backup by defining a new VM from a saved XML configuration and disk images.

Before you begin

Procedure

  1. Inspect the backup XML configuration of the VM for the specific storage settings.
    # cat </path/to/backup.xml>

    Example output section:

    <disk type='file' device='disk'>
          <driver name='qemu' type='qcow2' discard='unmap'/>
          <source file='/var/lib/libvirt/images/vm-name.qcow2' index='3'/>
  2. Move the backup disks to the locations specified in the backup XML and ensure that their names correspond with the values in the XML.
  3. Define a new VM based on the backup XML.
    # virsh define --file </path/to/backup.xml>
  4. Optional: Modify the XML configuration of the newly created VM to adjust for settings that might be different from the original host, such as the network.
    # virsh edit <vm_name>

Results

  • Start the VM and check that the guest operating system has been recovered correctly.
    # virsh start <vm_name>