xtrabackup基本使用
xtrabackup--一款基于innodb的热备份工具,支持完全备份,增量备份
## 一、特点
1.物理上的备份
2.备份过程不会打断执行的事务
3.自动备份检验
页大小,page:16k
## 二、备份案列
### 准备工具
wget https://downloads.percona.com/downloads/Percona-XtraBackup-2.4/Percona-XtraBackup-2.4.23/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.23-1.el7.x86_64.rpm
yum install percona-xtrabackup-24-2.4.23-1.el7.x86_64.rpm -y
LSN(log sequ):日志序列号
### 1、完全备份
mkdir /backup
xtrabackup --backup --target-dir=/backup
scp -r /backup/ 192.168.48.71:/
xtrabackup --prepare --target-dir=/backup/
xtrabackup --copy-back --target-dir=/backup/
chown -R mysql.mysql /data/mysql/
### 2、增量备份
xtrabackup --backup --target-dir=/backup/base
insert teachers (name,age) values('wang',20);
xtrabackup --backup --target-dir=/backup/inc1 --incremental-basedir=/backup/base
insert teachers (name,age) values('zhang',20);
xtrabackup --backup --target-dir=/backup/inc2 --incremental-basedir=/backup/inc1
scp -r /backup/ 192.168.48.71:/
**目标主机**
du -sh /backup/*
xtrabackup --prepare --apply-log-only --target-dir=/backup/base
du -sh /backup/*
xtrabackup --prepare --apply-log-only --target-dir=/backup/base --incremental-dir=/backup/inc1
du -sh /backup/*
xtrabackup --prepare --target-dir=/backup/base --incremental-dir=/backup/inc2
systemctl stop mariadb
rm -rf /data/mysql/*
ll /data/mysql/
xtrabackup --copy-back --target-dir=/backup/base
du -sh /data/mysql/
chown -R mysql.mysql /data/mysql/
systemctl start mariadb