Monday, March 9, 2015

Re: [fedora-virt] How to revert an external snapshot

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJU/cxjAAoJEKeha0olJ0Nq64YIAIQe3gaE6O7TkjfbOjVoQWr5
rYGIuUbt8863FBJRUce5Sn+3j2ZV/7yg6RYF+3L/GuIkXDrLkR7UYlUzaqHXuyYY
pzWraCAJIvccFI+1ycZCU1WkwLHkpOXeyzQqzQIwFM/547k04jEXsDwBr4JUTczX
+FaZr86PKOL2ZnzAY0pcYb63gohaQh6LAvo1ME82ICirZ11/AlkpocBVzOsBY5z3
HdG8SyIhncx24iLIgd2n1kKK850kOIW7lqRCfifpH01EI/DkcrqrjFNvqyWin7z2
4hdbXTiaopmsQf7vI8Wrs/E5e/rNhRqeTqX46XXu3ZCcciMWuX+6aWD/WKbRpXg=
=E+wx
-----END PGP SIGNATURE-----
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

No comments:

Post a Comment