I have created multiple KVM VMs using QCOW2 images.
Each VM has its own qcow2 file and is not based on any backing file.
My question is specifically related to snapshots of QCow2 images on these running VMs.
If I run the following command on a running VM :
qemu-img snapshot -c backup /vms/vm10001.qcow2
Will the above command harm the running VMs filesystem ?
My intention is to then convert the snapshot into a qcow2 image using the following :
qemu-img convert -s backup /vms/vm10001.qcow2 /vms/output.qcow2
I am unable to use the "virsh" commands and hence I am trying to figure out a way to do my task with qemu-img
Answer / Update 1 :
Ok, so I tested this on several of my test VMs and the above is not possible. You cannot run qemu-img snapshot
on a live VM without pausing it.
The only way to do it on RHEL base Nodes is to use :
virsh snapshot-create <dom>
The above will save the VM state and internally then call qemu-img snapshot -c
. However this can take some time which brings me to my second question
Question 2 :
virsh snapshot-create <dom> --disk-only --atomic
is not supported on base Nodes which are RHEL types (including RHEL 7) because the qemu-kvm is very old.
So the only option is to use virsh snapshot-create <dom>
which is kind of slow.
Is it possible to do the following :
virsh suspend <dom>
qemu-img snapshot -c backup /vms/<dom>.qcow2
virsh resume <dom>
The above operation seems to be much faster than snapshot-create
Answer / Update 2 :
Even the above question 2 is not possible. After doing a lot of research I have concluded the same.
Question 3 :
Is there any method to create a snapshot for an online VM having a Qcow2 disk on a RHEL 6 / 7 base node and then make a backup of the snapshot for restore later on ?
Best Answer
This not an exact answer but will show you the way.
We are using linux KVM for a long time. In old days qcow2 did not support snapshots. In our first KVM host we did not want to use LVM snapshots and because of that we could not take live backups.
Then we found Linux Hot Copy Tools.
Using this tool; we could freeze whole host filesystem and copied qcows to external disks with a custom backup script.
Our backup script was something like this;