参考:https://www.percona.com/doc/percona-xtrabackup/2.4/backup_scenarios/incremental_backup.html 先做正常的全量备份。然后,假设有两次增量备份,分别按如下方式执行:
# xtrabackup --backup --user=root --password=root123 \ --target-dir=/opt/backup/inc1 --incremental-basedir=/opt/backup/base
# xtrabackup --backup --user=root --password=root123 \ --target-dir=/opt/backup/inc2 --incremental-basedir=/opt/backup/inc1
全量备份时,重放已提交事务并回滚未提交事务;但在增量备份时,不回滚未提交事务,因为事务有可能在下一个增量备份提交。
参数
--apply-log-only
告诉xtrabackup不回滚未提交事务。
而在最后一个增量备份时不使用该参数。
xtrabackup --prepare --apply-log-only --target-dir=/opt/backup/base
xtrabackup --prepare --apply-log-only --target-dir=/opt/backup/base \ --incremental-dir=/opt/backup/inc1
xtrabackup --prepare --target-dir=/opt/backup/base \ --incremental-dir=/opt/backup/inc2
增量备份的restore方法同全备,restore的target-dir是/opt/backup/base。
xtrabackup --copy-back --target-dir=/opt/backup/base
