Xtrabackup備份

#上傳文件包mysql

[root@k8s-maste1]# rz percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpmsql

#下載epel源ide

wget -O /etc/yum.repos.d/epel.repo  https://mirrors.aliyun.com/repo/epel-7.repospa

#安裝依賴orm

yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQLrem

#下載Xtrabackupget

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.rpmit


#安裝io

[root@k8s-maste1]# yum localinstall -y percona-xtrabackup-24-2.4.4-1.el7.x86_64.rpmast

#安裝好後的命令

[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

相關文章
相關標籤/搜索