2020-03-03备份恢复xbk

 安装依赖包:

wget-O/etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repoyum-y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL libev

下载软件并安装

wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.12/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpmhttps://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpmyum-y install percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm


innobackupex使用


[root@db01 backup]# innobackupex --user=root --password=123 -S /tmp/mysql.sock --no-timestamp /backup/full

innobackupex --apply-log /backup/full  追平lsn号  模拟csr的过程

cat xtrabackup_binlog_info

mysql-bin.000007        194    5b65d91d-5bb1-11ea-b30e-000c291bec8a:1-8

记录二级制信息

重启数据库会刷新一个新的二级制日志

cat xtrabackup_checkpoints

差九个数说明没有增量

增量备份:

--incremental  开关

--incremental-basedir=/backup/full  基于full进行增量

innobackupex --user=root --password=123 -S /tmp/mysql.sock --no-timestamp --incremental --incremental-basedir=/backup/full /backup/new

备份恢复加增量加binlog:

innobackupex--apply-log--redo-only /backup/full   

合并 innobackupex --apply-log --redo-only --incremental-dir=/backup/new /backup/full

最后整理

innobackupex --apply-log /backup/full

截取二进制

起点:cat /backup/inc2/xtrabackup_binlog_info

终点:mysqlbinlog /data/binlog/mysql-bin.000008 |grep 'SET'

mysqlbinlog--skip-gtids--include-gtids='1afe8136-601d-11e9-9022-000c2928f5dd:7-9'/data/binlog/mysql-bin.000009>/data/backup/binlog.sql

cp-a*/data/mysql/data2

chown-R mysql./data/*

systemctl stop mysqld

vim /etc/my.cnf

datadir=/data/mysql/data2

systemctl start mysqld

Master [(none)]>set sql_log_bin=0;

Master [(none)]>source /data/backup/binlog.sql

你可能感兴趣的:(2020-03-03备份恢复xbk)