[libvirt-users] KVM incremental backup using CBT

Thomas Stein himbeere at meine-oma.de
Sun Nov 2 13:13:32 UTC 2014


> > A quick google search found this:
> > http://callecalle.uach.cl/ovirt-engine/docs/manual/en_US/html/Technical_Gu
> > id e/QEMU_Guest_Agent_Overview.html
> > 
> > Sadly, it didn't spell out the name of where you install hook scripts
> > into the guest.  But this commit is pretty telling:
> > https://github.com/qemu/qemu/blob/master/scripts/qemu-guest-agent/fsfreeze
> > -h ook

After a little bit of fiddling i've got this running. Here is what's 
neccessary in case someone wanna try this too.

qemu-guest.-agent has to run with the option: "-F /etc/qemu/fsfreeze-hook". 
This file contains as pointed out by Eric:

https://github.com/qemu/qemu/blob/master/scripts/qemu-guest-agent/fsfreeze-hook

Then you need to have a directory called /etc/qemu/fsfreeze-hook.d. Inside 
this directory this mysql-flush script:

https://github.com/qemu/qemu/blob/master/scripts/qemu-guest-agent/fsfreeze-hook.d/mysql-flush.sh.sample

I had to adjust this script a little for mariadb 10.0.14. But after that 
everything works as expected.

Here the output:

Sun  2 Nov 13:46:14 CET 2014: execute /etc/qemu/fsfreeze-hook.d/mysql-flush 
freeze
+ MYSQL='mysql -uroot -ppassword'
+ FIFO=/tmp/mysql-flush.fifo
+ case "$1" in
+ mkfifo /tmp/mysql-flush.fifo
+ flush_and_wait
+ printf 'FLUSH TABLES WITH READ LOCK \G\n'
+ mysql -uroot -ppassword
+ read
++ echo 'SHOW STATUS LIKE "Key_blocks_not_flushed"'
++ mysql -uroot -ppassword
++ tail -1
++ cut -f 2
+ '[' 0 -gt 0 ']'
++ mktemp /tmp/mysql-flush.XXXXXX
+ INNODB_STATUS=/tmp/mysql-flush.eTdvA4
+ '[' 0 -ne 0 ']'
+ trap 'rm -f /tmp/mysql-flush.eTdvA4' SIGINT
+ :
+ printf 'SHOW ENGINE INNODB STATUS \G'
+ mysql -uroot -ppassword
++ grep 'Log sequence number' /tmp/mysql-flush.eTdvA4 tr -s ' '
++ cut '-d ' -f4
+ LOG_CURRENT=12242169543
++ grep 'Log flushed up to' /tmp/mysql-flush.eTdvA4 tr -s ' '
++ cut '-d ' -f7
+ LOG_FLUSHED=12242169543
+ '[' 12242169543 = 12242169543 ']'
+ break
+ rm -f /tmp/mysql-flush.eTdvA4
Sun  2 Nov 13:46:14 CET 2014: /etc/qemu/fsfreeze-hook.d/mysql-flush finished 
with status=0
Sun  2 Nov 13:46:14 CET 2014: execute /etc/qemu/fsfreeze-hook.d/mysql-flush 
thaw
+ MYSQL='mysql -uroot -ppassword'
+ FIFO=/tmp/mysql-flush.fifo
+ case "$1" in
+ '[' '!' -p /tmp/mysql-flush.fifo ']'
+ echo
+ rm -f /tmp/mysql-flush.fifo
+ printf 'UNLOCK TABLES \G\n'
Sun  2 Nov 13:46:14 CET 2014: /etc/qemu/fsfreeze-hook.d/mysql-flush finished 
with status=0

Just to be sure i activated the general.log for mysql:

141102 13:46:14     6 Connect   root at localhost as anonymous on 
                    6 Query     select @@version_comment limit 1
                    6 Query     FLUSH TABLES WITH READ LOCK
                    7 Connect   root at localhost as anonymous on 
                    7 Query     select @@version_comment limit 1
                    7 Query     SHOW STATUS LIKE "Key_blocks_not_flushed"
                    7 Quit      
                    8 Connect   root at localhost as anonymous on 
                    8 Query     select @@version_comment limit 1
                    8 Query     SHOW ENGINE INNODB STATUS
                    8 Quit      
                    6 Query     UNLOCK TABLES
                    6 Quit

Nice!

cheers
t.




More information about the libvirt-users mailing list