[fedora-virt] How to revert an external snapshot

Eric Blake eblake at redhat.com
Mon Mar 9 16:37:55 UTC 2015


On 03/09/2015 02:40 AM, Dario Lesca wrote:
> Il giorno mer, 04/03/2015 alle 12.01 -0500, Cole Robinson ha scritto:
>> For that last bit, you should be able to do:
>>
>> sudo virsh snapshot-delete --metadata $snapshot-name
> 
> Thanks Cole, and thanks also to Kashyap for the useful link.
> 
> But, for me, traslate this info into a procedure (shell script) for do
> an hot backup/restore of my virtual machine is difficult.
> 
> I intend use external snapshot for transfer, without poweroff, a guest
> from host to bk-host.
> 
> With external snapshot, my idea was to transfer the base image from host
> to bk-host and, at the end of copy base image, to remove the snapshot on
> host.
> 
> It's possible to do that or something like this?

Yes.  It sounds like this will do it:

# Create the external snapshot
virsh snapshot-create $dom --no-metadata --disk-only
# Copy the base image to bk-host, for an appropriate $copy
"$copy" host... bk-host...
# Commit the temporary qcow2 snapshot wrapper back into the main disk
foreach disk in $dom:
  virsh blockcommit $dom $disk --active --shallow --verbose --pivot

and now your host is back to executing with the original file as active,
with no notion that a backup was taken in the meantime, and with guest
downtime limited to millisecond or less ranges.  The backup image now
stored on bk-host is not consistent (that is, libvirt still needs to add
support for a 'snapshot-create --quiesce' flag); if that matters, you
can use this longer sequence (assuming you have new enough libvirt):

virsh domfsfreeze $dom
virsh snapshot-create $dom --no-metadata --disk-only
virsh domfsthaw $dom
"$copy" host... bk-host...
etc.

> there is already some scripts?

I don't know if anyone else has tried to script it, but I haven't.

> 
> Thanks for your help ... and great work.
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://lists.fedoraproject.org/pipermail/virt/attachments/20150309/78bfa93b/attachment.sig>


More information about the virt mailing list