Restoring a KVM VM from the .qcow2 file

I’m running Fedora Server 41 and created a VM in KVM. My crude way of backup was to shutdown the VM weekly, make a copy of the .qcow2 file (located on /var/lib/libvirt/images) and the xml definition (located in /etc/libvirt/qemu).

I have copied these two files to another server but for some strange reason I can’t find the .xml file. I have the copy of the image .qcow2 but not the definition. The disk on the server is damaged so can’t access it anymore.

Is there a way for me to recreate the .xml file using qemu-img on the .qcow2 file or other commands? It’s a big lesson in backup management but I first need to get this VM up and running again.

Any help would be much appreciated

Create a new VM and tell it to use your existing .qcow2 file.
Of course you will have to get the hardware options right to support your VM.
You should be able to interate the options to get that right.

Make sure you have a copy of the .qcow2 image incase you have to start again.

1 Like

Thank you, thank you, thank you. That worked a treat.

Coming back to the topic of backups how do you take backups of VMs?

Hi, do you use virt-manager? It has the option to snapshot your VM, see

For cli tool virsh, following guide has useful information:

I have a simple setup.
My VM backups are taken with the VMs stopped.
I backup the .xml and .qcow2 files.

1 Like