下载XtraBackup:

# wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.6/binary/tarball/percona-xtrabackup-2.4.6-Linux-x86_64.tar.gz

解压软件:

# tar xvf percona-xtrabackup-2.4.6-Linux-x86_64.tar.gz -C /usr/local/

# cd /usr/local/

# mv percona-xtrabackup-2.4.6-Linux-x86_64/ xtrabackup

设置环境变量:

# echo "export PATH=/usr/local/xtrabackup/bin:\$PATH">>/etc/profile

# source /etc/profile

安装依赖包:

yum install -y perl-Digest-MD5

全备数据库:

[mysql@publicserver ~]$ innobackupex --defaults-file=/etc/my.cnf --user=root --password=centos --socket=/var/lib/mysql/mysql.sock /mysqlbk

增量备份数据库:

[mysql@publicserver ~]$ innobackupex --defaults-file=/etc/my.cnf --user=root --password=centos --socket=/var/lib/mysql/mysql.sock --incremental --incremental-basedir=/mysqlbk/2017-03-26_21-56-46 /mysqlbk_rec

全备恢复准备:

[mysql@publicserver ~]$ innobackupex --defautls-file=/mysqlbk/my.cnf --apply-log --redo-only /mysqlbk/2017-03-26_21-56-46

增量恢复准备:

[mysql@publicserver ~]$ innobackupex --defaults-fil=/mysqlbk/my.cnf --apply-log /mysqlbk/2017-03-26_21-56-46 --incremental-dir=/mysqlbk_rec/2017-03-26_21-57-11

执行 innobackupex --apply-log:

[mysql@publicserver ~]$ innobackupex --defautls-file=/mysqlbk/my.cnf --apply-log /mysqlbk/2017-03-26_21-56-46

执行恢复:

[mysql@publicserver ~]$ innobackupex --defaults-file=/mysqlbk/my.cnf --socket=/var/lib/mysql/mysql.sock --copy-back /mysqlbk/2017-03-26_21-56-46

压缩备份集:

[mysql@publicserver ~]$ innobackupex --defaults-file=/usr/local/mysql/my.cnf --user=root --password=centos --socket=/tmp/mysql.sock --stream=tar /tmp | gzip ->/mysqlbk/mysql_fullbackup.tar.gz