[virt-tools-list] Best way to backup my VMs

Eric Blake eblake at redhat.com
Tue Apr 12 14:40:17 UTC 2011

On 04/12/2011 08:18 AM, Richard W.M. Jones wrote:
>> Is it possible to "pause" a machine with a simple command, rsync the
>> machine's HD image in other computer and then safelly resume the machine? Is
>> it necessary to shut down the virtual machine, in order to make this backup?
> You are best to install some backup software into the virtual machine.
> Treat the virtual machine like it was a physical machine and back it
> up with some software which is aware of what's going on inside.

That is indeed the safest advice.

But in answer to the question, yes, it is possible to pause a guest,
save the state of its memory and disks (saving just one or the other is
insufficient - you need to save both, otherwise, in-flight data in
memory that has not been flushed to disk will be corrupted).  That is,
use the sequence:

virsh save domain file # saves the memory state, and pauses the guest
copy all the disk images # saves the disk state
virsh restore file # resumes the guest

to make your snapshot.  If you have to restore from that snapshot, then
be sure that you revert the disks back to the saved state before
re-issuing the virsh restore.  And while this does pause the guest, it
at least has the advantage of not having to reboot the guest.

There is work underway on the upstream libvirt list to improve snapshot
abilities (right now, there is a 'virsh snapshot' command which takes a
snapshot of disk state, but it currently only works for qcow2 disks and
doesn't capture the corresponding memory state); the goal is to expand
it to work with lvm and btrfs snapshots for faster response (all three
of those technologies support copy-on-write overlays, which means the
snapshot is an O(1) instead of O(n) operation), as well as making it
easier to do O(n) snapshots for other disk formats such as raw images.

Additionally, libvirt would like to support live snapshots, where qemu
can interact with snapshot mechanisms as well as pause I/O traffic to
the disks to allow the creation of a copy-on-write overlay which can
allow copying the snapshot while the guest continues to run (much better
than the current conditions which require the guest to be paused for the
duration of the disk copy, which can be rather lengthy downtime).  And
the best solution requires interaction with the guest to request that it
quiesce its file systems.  Security considerations dictate that libvirt
must never depend on guest actions; therefore quiescing must be treated
as a suggestion, just like memory ballooning, where libvirt will operate
correctly even if the guest ignores the request.  But for guests that
honor a quiesce request, it is easier to perform a snapshot operation
because then you can get away with just snapshotting the disk images
instead of having to also snapshot memory contents for in-flight I/O

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20110412/ac8932aa/attachment.sig>

More information about the virt-tools-list mailing list