Вы находитесь на странице: 1из 6
Gonzalo Marcote | Open source, open mind Página personal Inicio Perfil Profile Proyectos Goals

Inicio kvm › KVM – Live backups with qcow2

Inicio › kvm › KVM – Live backups with qcow2 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:

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

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

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 ensure you have a consistent disk state. Check this post for install it ->

.] to

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

 

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

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

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

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…):

 
 

About snapshots:

 

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

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.

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

$ rm /mnt/local/nas/backups/libvirt/images/hermes-snap1.qcow2 1 Pings/Trackbacks para "KVM – Live backups with
$ 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-backups-
with-qcow2) […]
Deja un comentario
Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *
Comentario

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

   
         
 
         
   
Nombre *

Nombre *

Nombre *
   
 
   
 
Correo electrónico *

Correo electrónico *

Correo electrónico *
   
 
   
 
Web

Web

Web
   
 
   
 
Correo electrónico *     Web     Publicar comentario           ©
Correo electrónico *     Web     Publicar comentario           ©

Publicar comentario

   
Web     Publicar comentario           © 2016 Casi ningún derecho
Web     Publicar comentario           © 2016 Casi ningún derecho
Web     Publicar comentario           © 2016 Casi ningún derecho
Web     Publicar comentario           © 2016 Casi ningún derecho
 
 
 
 
 
 
 

 

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