16、xtrabackup 增量备份及恢复
备份命令如下
全量备份
# innobackupex -p123123 /backup
# ls /backup
2017-04-08_13-36-11
增量备份或差量备份
# innobackupex -p123123 --incremental /backup --incremental-basedir=/backup/2017-04-08_13-36-11/
# ls /backup/
2017-04-08_13-36-11 2017-04-08_13-41-59
# innobackupex -p123123 --incremental /backup --incremental-basedir=/backup/2017-04-08_13-41-59
# ls /backup
2017-04-08_13-36-11 2017-04-08_13-41-59 2017-04-08_14-01-16
恢复命令
> scp -r /backup/* 192.168.1.120:/testdir/
> innobackupex --apply-log --redo-only --use-memory=1G /testdir/2017-04-08_13-36-11/
> innobackupex --apply-log --redo-only --use-memory=1G /testdir/2017-04-08_13-36-11/ --incremental-dir=/testdir/2017-04-08_13-41-59
> innobackupex --apply-log --use-memory=1G /testdir/2017-04-08_13-36-11/ --incremental-dir=/testdir/2017-04-08_14-01-16
> systemctl stop mariadb
> rm -rf /var/lib/mysql/*
> innobackupex --datadir=/var/lib/mysql --copy-back /testdir/2017-04-08_13-36-11
> chown -R mysql: /var/lib/mysql/
> systemctl start mariadb