Why can't I just copy a .qcow2 file in KVM, while the VM is stopped, as a backup?
Linux - Virtualization and CloudThis forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why can't I just copy a .qcow2 file in KVM, while the VM is stopped, as a backup?
Hi Guys
I've got a stupid question - I've got a fully configured Centos 6-running VM running just fine inside a KVM instance inside of Centos 6. E. g. Centos-in-a-Centos.
The virtual disk file is in qcow2 format and has a set size of 1 TB - due to qcow2 being sparse (right?) it is about 200 GB in actual size.
It seems very complicated (and dangerous) to "snapshot" the running VM to try and make a backup of the actual physical qcow2 file.
Is there any reason why I cannot just copy the qcow2 file in its entirety (while the VM is NOT running!) and move this file to a backup medium, as a backup of the entire VM?
Will this file then work if the physical hardware fails and I can recreate a KVM instance, and just copy it back and start it up again?
I've been googling like mad, but all suggested solutions never mention this, so I assume I'm totally ass-backward in thinking a simple "copy the dead VM's qcow2 file somewhere" will work to effectively backup the entire VM machine? Am I wrong or right as regards this?
What are snapshots for then, if not to backup? Sorry, quite new to virting.
several things
1. backing up a disk image will give you nothing but a disk image. You also need the VM definitions (virsh dumpxml VMNAME > backup.xml)
2. backing up the base image of a VM, while the VM runs off of a live snapshot is not very safe, if the live snapshot wasn't done during a guest's quiesce time. Restoring a VM with such an image will not be consistent, you'll end up with a VM that's in the same state as if you started a machine that had it's cable pulled out while it was working. You need to coordinate a quiesce command in the guest, with the taking of the live snapshot, and even that doesn't give 100% confidence, because you still don't have the VM's current system state.
If you have the disk image and the VM definitions backed up, you can start it on any other KVM/libvirt host later on, with, maybe, some tweaks to the definition XML, if it contained anything host specific
The copied image ought to be bootable from qemu. Try it just to see maybe.
Simple command line qemu imagename.cqow2 or qemu -hda imagename.cqow2
There are a lot of posts that more deal with live state backups. The powered off image ought to be a disk image of the virtual computer. It could in some cases be converted. It may depend on exactly what the use of this is for. Complete recover of data or just redundancy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.