mysql full backup xtrabackup (innobackupex) mode

mysql full backup xtrabackup (innobackupex) mode

1. Download and install xtrabackup
https://www.percona.com/downloads/Percona-XtraBackup-LATEST/
install

yum -y install perl perl-devel libaio libaio-devel perl-Time-HiRes perl-DBD-MySQL libev-devel
rpm -ivh percona-xtrabackup-24-2.4.9-1.el7.x86_64.rpm

View

rpm  -ql   percona-xtrabackup-24
Insert picture description here


Backup mode view

 man innobackupex
Insert picture description here


2. Create a user dedicated to database backup

grant reload,process,lock tables,replication client on *.* to 'admin'@'localhost'   identified by '123456';
flush privileges;
Insert picture description here


3. Backup

//备份
innobackupex --user=admin  --password=123456  /full_xtrabackup
//查看备份
 cd /full_xtrabackup/2021-06-02_10-37-32
Insert picture description here


Insert picture description here


4. Preparation
Combine the backup file with the log file generated during the backup

innobackupex --apply-log --redo-only --user=admin  --password=123456 /full_xtrabackup/2021-06-02_10-37-32/

5. Manufacturing failure

 rm -rf /usr/local/mysql/data/*

At this time, the database instance is started and the data can be accessed, but there are no more tables in the database

Close mysql

pkill -9 mysqld

6. Start to restore the backup

innobackupex --copy-back  /full_xtrabackup/2021-06-02_10-37-32/
Insert picture description here


Modify file permissions

cd /usr/local/mysql
chown -R mysql.mysql .

7. Restart the MySQL service

service mysql start