Sei sulla pagina 1di 6

Gonzalo Marcote | Open source, open mind

Pgina personal

Inicio

Perfil

Profile

Proyectos

Goals

Contacto

Inicio kvm KVM Live backups with qcow2

KVM Live backups with qcow2


Publicado en 17 noviembre, 2014 por Gonzalo 1 comentario

I was looking for some resources to do one simple guest disk live backup without stooping the guest.
And it was resulting difficult to me to find one official, simple and elegant way of doing it. All the options ends with
the guest running with another snapshot disk.
After spending some time reading I have found this:
http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit
So the process to do one live disk backup while the guest is running (with qcow disks of course), could be this one:
1. List the current block device in use:
# virsh domblklist hermes
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Target Source
-----------------------------------------------vda /var/lib/libvirt/images/hermes.qcow2
2. Create an external disk snapshot:
# virsh snapshot-create-as --domain hermes hermes-snap1 --disk-only --atomic --quiesce

disk-only -> option, takes the snapshot only for the disk
atomic -> just ensures either the snapshot is run completely or fails w/o making any
changes
quiesce -> if you have QEMU guest agent installed in your virtual machine (apt-get
install qemu-guest-agent), try quiesce option with virsh snapshot-create-as[. . .] to
ensure you have a consistent disk state. Check this post for install it ->
http://www.gonzalomarcote.com/2014/qemu-guest-agent/

3. Now that the guest is using the external snapshot disk we can take a backup of the original disk in backround
using your faviourite tool. Rsync for example:
# rsync -avh --progress /var/lib/libvirt/images/hermes.qcow2
/mnt/local/nas/backups/libvirt/images/hermes-snap1.qcow2
4. When the backup is finished, perform active blockcommit by live mergning contents of hermes-snap1 into base:
# virsh blockcommit hermes vda --active --verbose --pivot
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Block Commit: [100 %]


Successfully pivoted
List the current block device in use, again. It can be noticed, once the blockcommit operation is completed, the live
QEMU is pivoted to the base image again:
# virsh domblklist hermes
Target Source
-----------------------------------------------vda /var/lib/libvirt/images/hermes.qcow2
5. Finaly, if we want, we can remove the external snapshot to not to leave it there:
# virsh snapshot-list hermes
Name Creation Time State
-----------------------------------------------------------hermes-snap1 2014-11-17 16:29:09 +0100 disk-snapshot
# virsh snapshot-delete hermes hermes-snap1 --metadata
Domain snapshot hermes-snap1 deleted
# virsh snapshot-list hermes
Name Creation Time State
-----------------------------------------------------------and we are done
For this blockcommit backup option you need a quite recent libvirt and qemu versions. Debian wheezy versions are
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

quite old but you can install them from wheezy-backports:


ii libvirt-bin 1.2.9-3~bpo70+
ii qemu 2.1+dfsg-5~bpo
All the credits to kashyapc (certainly a great blog to follow):
http://wiki.libvirt.org/page/Live-disk-backup-with-active-blockcommit
http://kashyapc.com/2014/10/07/libvirt-blockcommit-shorten-disk-image-chain-by-live-merging-the-current-activedisk-content/
About snapshots:
http://kashyapc.com/2011/10/04/snapshotting-with-libvirt-for-qcow2-images/
http://kashyapc.com/2012/09/14/externaland-live-snapshots-with-libvirt/

QEMU Guest Agent


Going from suspend into hibernate after some amount of time on Debian Jessie, aka suspend sedation

Publicado en kvm, virtualization Etiquetado con: kvm, virtualizacion

Un comentario en KVM Live backups with qcow2

Fredy Paquet dice:


14 junio, 2016 a las 18:54

You forgot deleting the snapshot disk file after virsh snapshot-delete hermes hermes-snap1 metadata
Otherwise you will not be able to repeat the process, because the snapshot file already exists.
open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

$ rm /mnt/local/nas/backups/libvirt/images/hermes-snap1.qcow2

1 Pings/Trackbacks para "KVM Live backups with qcow2"

QEMU Guest Agent | Gonzalo Marcote | Open source, open mind dice:
3 diciembre, 2014 a las 21:59

[] This option is necessary for use virsh snapshot-create-as quiesce option that ensures you have a
consistent disk state when you do live backups (check http://www.gonzalomarcote.com/2014/kvm-live-backupswith-qcow2) []

Deja un comentario
Tu direccin de correo electrnico no ser publicada. Los campos obligatorios estn marcados con *
Comentario

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Nombre *

Correo electrnico *

Web

Publicar comentario

2016 Casi ningn derecho reservado. Comparte

Responsive Theme Creado con WordPress

open in browser PRO version

Are you a developer? Try out the HTML to PDF API

pdfcrowd.com

Potrebbero piacerti anche