#上传文件包
[root@k8s-maste1]# rz percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
#下载epel源
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
#安装依赖
yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL
#下载Xtrabackup
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.4/binary/redhat/7/x86_64/percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
#安装
[root@k8s-maste1]# yum localinstall -y percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpm
#安装好后的命令
[root@k8s-maste1]# xtrabackup
[root@k8s-maste1]# innobackupex
Xtrabackup全量备份
[root@k8s-maste1]# mkdir /backup
[root@k8s-maste1]# innobackupex --user=root --password=123 /backup/full
#去掉时间戳进行备份
[root@k8s-maste1]# innobackupex --user=root --password=123 --no-timestamp /backup/full
查看全备内容
[root@k8s-maste1]# ll /backup/full/
-rw-r----- 1 root root 434 12月 23 21:46 backup-my.cnf
drwxr-x--- 2 root root 68 12月 23 21:46 dump
-rw-r----- 1 root root 79691776 12月 23 21:46 ibdata1
-rw-r----- 1 root root 52428800 12月 23 21:46 ibdata2
drwxr-x--- 2 root root 4096 12月 23 21:46 mysql
drwxr-x--- 2 root root 4096 12月 23 21:46 performance_schema
drwxr-x--- 2 root root 68 12月 23 21:46 row
drwxr-x--- 2 root root 20 12月 23 21:46 test
-rw-r----- 1 root root 21 12月 23 21:46 xtrabackup_binlog_info
-rw-r----- 1 root root 113 12月 23 21:46 xtrabackup_checkpoints
-rw-r----- 1 root root 483 12月 23 21:46 xtrabackup_info
-rw-r----- 1 root root 2560 12月 23 21:46 xtrabackup_logfile
[root@k8s-maste1]# cat xtrabackup_checkpoints
backup_type = full-backuped
from_lsn = 0
to_lsn = 8417759
Xtrabackup增量备份
1.先全备
[root@k8s-maste1]# innobackupex --user=root --password=123 --no-timestamp /backup/full_$(date +%F)
2.写入新数据
[root@k8s-maste1]# mysql -uroot -p123
mysql> use haha
mysql> insert haha values(1),(2),(3);
3.增备
[root@k8s-maste1]# innobackupex --user=root --password=123 --no-timestamp --incremental --incremental-basedir=/backup/full_2020-12-23 /backup/inc1
参数说明:
--incremental:开启增量备份功能
--incremental-basedir:上一次备份的路径
#验证
[root@k8s-maste1]# cat /backup/full/xtrabackup_checkpoints
backup_type = full-prepared
from_lsn = 0
to_lsn = 8417759
[root@k8s-maste1]# cat /backup/inc1/xtrabackup_checkpoints
backup_type = incremental
from_lsn = 8417759
to_lsn = 8419281