KVM - libvert backup - vm backup

Soldato
Joined
18 May 2010
Posts
22,892
Location
London
I've been asked to backup a vm we have running on our Red Hat 6 server running KVM.

I've not done this before, so thought I'd ask here.

I've shut the quest down and want to create a back up.

Running virsh domblklist vmname shows me the location of a .img file.

Is it as simple as using cp to copy the .img file to another directory?

There is a lot of chatter on the internet about .xml files.

---

I just renamed to it to vmname.img.bak will this work? I.e if we need to restore it can I just rename it to vmname.img and it will be importable again?
 
Last edited:
Surprised nobody has answered this, though seeing as it's been five days I'm guessing you've found an answer!

You can run the following, presuming that the domain is called "testdomain":
Code:
virsh dumpxml testdomain > testdomain.xml

Then just copy the image. Good idea to pipe it into gzip for compression.

However, there are some considerations to make. Primarily, if this is going to be copied to a new system at some point, you'll want to make sure that the virtualised CPU architecture matches the host in most circumstances (though with Haswell* and Broadwell* you want the CPU type to be -noTSX).

Depending on how these VMs were created it may make sense just to recreate the VM with the existing hardware when a restoration is needed.
 
Last edited:
Back
Top Bottom