赞
踩
os: centos 7.4.1708
db: mysql 8.0.20
Usage: [xtrabackup [--defaults-file=#] --backup | xtrabackup [--defaults-file=#] --prepare] [OPTIONS]
--prepare
准备数据恢复
–prepare prepare a backup for starting mysql server on the backup.
The --prepare step makes the files perfectly consistent at a single instant in time, so you can run InnoDB on them.
--apply-log-only
不回滚事务
–apply-log-only stop recovery process not to progress LSN after applying log when prepare.
–apply-log-only should be used when merging all incrementals except the last one. Even if the --apply-log-only was used on the last step, backup would still be consistent but in that case server would perform the rollback phase.
# 一次 prepare 全量备份
# xtrabackup --defaults-file="/etc/mysql/my.cnf" --prepare --datadir=/var/lib/mysql --target-dir=/backup/backupset/20180327_base
前面恢复时需要增加 --apply-log-only ,阻止发生 rollback
最后一次恢复时,去除 --apply-log-only ,进行数据的回滚操作。
# 先 prepare 全量备份
# xtrabackup --defaults-file="/etc/mysql/my.cnf" --prepare --apply-log-only --target-dir=/backup/backupset/20180327_base
# 再 prepare 增量备份
# xtrabackup --defaults-file="/etc/mysql/my.cnf" --prepare --apply-log-only --target-dir=/backup/backupset/20180327_base --incremental-dir=/backup/backupset/20180327_inc1
# 再 prepare 全量备份
# xtrabackup --defaults-file="/etc/mysql/my.cnf" --prepare --target-dir=/backup/backupset/20180327_base
# xtrabackup --copy-back --datadir=/var/lib/mysql --target-dir=/backup/backupset/20180327_base
# chown -R mysql:mysql /var/lib/mysql/*
# systemctl start mysqld.service
参考:
https://docs.percona.com/percona-xtrabackup/2.4/howtos/recipes_xbk_full.html
https://docs.percona.com/percona-xtrabackup/2.4/howtos/recipes_xbk_inc.html
https://docs.percona.com/percona-xtrabackup/2.4/howtos/recipes_xbk_restore.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。