I am using a glusterfs storage with qcow2 files on it for months.
VMs are running fast, live migration works also fine.
But I was missing real live snapshot.

Internal qcow2 snapshots which are also dumping guest memory are working fine,
but they suspend during backup and it can take from few second to few minutes.

So I was searching for something like external snapshots,
but there was no way to blockcommit the delta file back to its original after backing it up.

But with recent CentOS7 and oVirt kvm repo, now it is possible!!!

  • Guest freezes during backup for less than 2 seconds (depends on your storage and system)
  • Memory is not dumped, as it is a diskonly backup
  • Backup is now possible by simply copy the qcow2 file
  • Delta file can now be committed back into original
  • Delta file can not be deleted with virsh, but there is a simple workaround, see below

I have written a prototype of backup tool, which can do cron based backup (external), restore and snapshot(internal)
http://www.bitbull.ch/dl/scripts/virsh-qcow-backup.sh

cheers, chris

[root@clue1 ~]# virsh domblklist vm10
Target     Source
------------------------------------------------
vda        /srv/vm/images/vm10.qcow2

[root@clue1 ~]# ls -l /srv/vm/images/vm10*
-rw-r--r--. 1 qemu qemu 2908291072 Jun 25 12:37 /srv/vm/images/vm10.qcow2

[root@clue1 ~]# virsh snapshot-list vm10
 Name                 Creation Time             State
------------------------------------------------------------

[root@clue1 ~]# virsh snapshot-create-as --domain vm10 snap --disk-only --atomic
Domain snapshot snap created

[root@clue1 ~]# virsh snapshot-list vm10
 Name                 Creation Time             State
------------------------------------------------------------
 snap                 2015-06-25 12:38:12 +0200 disk-snapshot

[root@clue1 ~]# virsh domblklist vm10
Target     Source
------------------------------------------------
vda        /srv/vm/images/vm10.snap

[root@clue1 ~]# ls -l /srv/vm/images/vm10*
-rw-r--r--. 1 qemu qemu 2908291072 Jun 25 12:38 /srv/vm/images/vm10.qcow2
-rw-------. 1 qemu qemu     197632 Jun 25 12:38 /srv/vm/images/vm10.snap

[root@clue1 ~]# cp /srv/vm/images/vm10.qcow2 /srv/vm/images/vm10.qcow2.bak

[root@clue1 ~]# ssh vm10 mkdir /test

[root@clue1 ~]# ssh vm10 touch /test/$(date +%H_%M_%S)

[root@clue1 ~]# ssh vm10 ls /test/
12_40_19

[root@clue1 ~]# virsh blockcommit vm10 vda --active --pivot  --verbose
Block Commit: [100 %]
Successfully pivoted

[root@clue1 ~]# virsh domblklist vm10
Target     Source
------------------------------------------------
vda        /srv/vm/images/vm10.qcow2

[root@clue1 ~]# virsh snapshot-list vm10
 Name                 Creation Time             State
------------------------------------------------------------
 snap                 2015-06-25 12:38:12 +0200 disk-snapshot

[root@clue1 ~]# virsh snapshot-delete vm10 snap --metadata
Domain snapshot snap deleted

[root@clue1 ~]# virsh snapshot-list vm10
 Name                 Creation Time             State
------------------------------------------------------------

[root@clue1 ~]# ls -l /srv/vm/images/vm10*
-rw-r--r--. 1 qemu qemu 2908356608 Jun 25 12:42 /srv/vm/images/vm10.qcow2
-rw-r--r--. 1 root root 2908291072 Jun 25 12:39 /srv/vm/images/vm10.qcow2.bak
-rw-------. 1 qemu qemu    3080192 Jun 25 12:40 /srv/vm/images/vm10.snap

[root@clue1 ~]# rm -f /srv/vm/images/vm10.snap

[root@clue1 ~]# ssh vm10 sync

[root@clue1 ~]# virsh destroy vm10
Domain vm10 destroyed

[root@clue1 ~]# virsh start vm10
Domain vm10 started

[root@clue1 ~]# ssh vm10 ls /test/
12_40_19

[root@clue1 ~]# virsh destroy vm10
Domain vm10 destroyed

[root@clue1 ~]# mv /srv/vm/images/vm10.qcow2 /srv/vm/images/vm10.qcow2.current

[root@clue1 ~]# mv /srv/vm/images/vm10.qcow2.bak /srv/vm/images/vm10.qcow2

[root@clue1 ~]# virsh start vm10
Domain vm10 started

[root@clue1 ~]# ssh vm10 ls /test/
ls: cannot access /test/: No such file or directory

[root@clue1 ~]# virsh snapshot-list vm10
 Name                 Creation Time             State
------------------------------------------------------------

[root@clue1 ~]# ls -l /srv/vm/images/vm10*
-rw-r--r--. 1 qemu qemu 2908553216 Jun 25 12:45 /srv/vm/images/vm10.qcow2
-rw-r--r--. 1 root root 2908553216 Jun 25 12:44 /srv/vm/images/vm10.qcow2.current

[root@clue1 ~]# rpm -qa | grep kvm
libvirt-daemon-kvm-1.2.8-16.el7_1.3.x86_64
qemu-kvm-ev-2.1.2-23.el7_1.3.1.x86_64
qemu-kvm-common-ev-2.1.2-23.el7_1.3.1.x86_64

[root@clue1 ~]# ls -1 /etc/yum.repos.d/*
/etc/yum.repos.d/CentOS-Base.repo
/etc/yum.repos.d/CentOS-CR.repo
/etc/yum.repos.d/CentOS-Debuginfo.repo
/etc/yum.repos.d/CentOS-fasttrack.repo
/etc/yum.repos.d/CentOS-Sources.repo
/etc/yum.repos.d/CentOS-Vault.repo
/etc/yum.repos.d/glusterfs-epel.repo
/etc/yum.repos.d/ovirt-3.5-dependencies.repo
/etc/yum.repos.d/ovirt-3.5.repo