[fedora-virt] How to revert an external snapshot

Kashyap Chamarthy kashyapc at fedoraproject.org
Mon Mar 9 17:10:43 UTC 2015

On Mon, Mar 09, 2015 at 10:37:55AM -0600, Eric Blake wrote:
> 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

The above procedure (derived from mailing lists conversation with Eric)
is documented here with a little more commentary:



> 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

Thanks for the 'domfsthaw' reminder, I forgot about it.

> "$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.

More information about the virt mailing list