xtrabackup全量+增量+mysqlbinlog恢复数据到指定时间点

从上到下依次执行

xtrabackup/bin/innobackupex --defaults-file=/user/mysql/my.cnf --user root --use-memory=4G --apply-log --redo-only  /home/mysql/full/sun/

xtrabackup/bin/innobackupex --defaults-file=/user/mysql/my.cnf --user root --apply-log -use-memory=4G /home/mysql/full/sun/ --incremental-dir=/home/mysql/full/1

注:多次恢复增量点时除了最后一个其他需要添加参数--redo-only

xtrabackup/bin/innobackupex --defaults-file=/user/mysql/my.cnf --user root --apply-log --use-memory=4G /user/mysql/full/sun/

rm -rf /home/mysql/data/*

xtrabackup/bin/innobackupex --defaults-file=/user/mysql/my.cnf --user root --use-memory=4G --copy-back /user/mysql/full/sun/

cd /user/mysql/data/

chown mysql.mysql -R *

chmod 770 -R *

检查是否有老的binlog目录 跟现有的冲突


mv /user/binlog /user/binlog_old
mkdir /user/binlog
chown mysql:mysql -R /user/binlog

重启mysql *****必须****


/user/mysql/stop.sh
/user/mysql/start.sh

查看恢复到的pos值


cd /user/mysql/full/sun/
cat xtrabackup_binlog_info
binlog_pos = filename 'mysql-bin.00349', position '1113964'

binlog恢复增量之后的数据到需要的时间点


time /user/mysql/bin/mysqlbinlog /user/mysql/mysql-bin.00349 --start-position=1113964 --stop-datetime='2018-08-18 12:30:01'|/user/mysql/bin/mysql -u root -p

登录mysql查看数据恢复是否有问题

你可能感兴趣的:(xtrabackup全量+增量+mysqlbinlog恢复数据到指定时间点)