percona-xtrabackup-8.0.7 simple and quick to use
# References:
https://blog.csdn.net/vkingnew/article/details/83012316
# Environment: centos6.x
yum -y install perl-DBI yum -y install perl-DBD-MySQL yum -y install perl-IO-Socket-SSL.noarch yum -y install perl-Time-HiRes yum -y install perl-TermReadKey yum -y install perl-ExtUtils-MakeMaker [root@dbhost ~]# rpm -qa|grep libgcrypt libgcrypt-1.4.5-12.el6_8.x86_64
# Download the corresponding version
cd /opt/ wget https://www.percona.com/downloads/Percona-XtraBackup-LATEST/Percona-XtraBackup-8.0-7/binary/tarball/percona-xtrabackup-8.0.7-Linux-x86_64.libgcrypt145.tar.gz tar -zxf percona-xtrabackup-8.0.7-Linux-x86_64.libgcrypt145.tar.gz cd /usr/local/ ln -s /opt/percona-xtrabackup-8.0.7-Linux-x86_64 xtrabackup ln -fs /opt/percona-xtrabackup-8.0.7-Linux-x86_64/bin/* /usr/bin/ xtrabackup -v
# Create a dedicated backup account in the main library
create user 'bk_user'@'10.192.30.%' identified WITH mysql_native_password by 'v9SimLKsIHpwzyOgVwlM' PASSWORD EXPIRE NEVER ; GRANT BACKUP_ADMIN,SELECT, RELOAD, PROCESS, SUPER, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT, SHOW VIEW ON *.* TO 'bk_user'@'10.192.30.%';
# Full backup (backup from the local library)
xtrabackup --defaults-file=/data/mysql/mysql_3306/my_3306.cnf --host=10.192.30.60 --user='bk_user' --password='v9SimLKsIHpwzyOgVwlM' --port=3306 --backup --compress --compress-threads=8 --use-memory=4G --slave-info --parallel=8 --target-dir=/data/backup/
# Full amount of recovery
# Want to empty the file and its directory under the data directory
-- rm -rf tmp/* undolog/* data/* logs/mysql-bin*
# First extract, need to be installed separately
/ * Wget http://www.quicklz.com/qpress-11-linux-x64.tar tar xvf QPress-11-Linux-x64.tar cp QPress / usr / bin # If you can not download, log on to their official website, download alone and then upload
* / xtrabackup - Defaults =-File / Data / MySQL / mysql_3306 / my_3306.cnf --use-4G Memory --decompress --parallel = =. 8 --remove-Original---target the dir = / Data / backup / # compressed backup xtrabackup - Defaults =-File / Data / MySQL / mysql_3306 / my_3306.cnf --prepare --use-4G Memory --parallel = =. 8---target the dir = / Data / backup / # recovery data xtrabackup - Defaults =-File / data / MySQL / mysql_3306 / my_3306.cnf --copy-Back-Memory --use = =. 8 --target-4G --parallel the dir = / data / Backup / copy would # directory is located, is recommended to use --copy-back way, because of my my.cnf configuration path is dispersed chown-R mysql.mysql *
# Appendix: Simple is perfect shell script
#!/bin/bash # file_name: /usr/local/scripts/full_xtrabackup.sh # ################################################################################################################################################################# # # # create user 'bk_user'@'10.192.30.%' identified WITH mysql_native_password by 'v9SimLKsIHpwzyOgVwlM' PASSWORD EXPIRE NEVER ; # GRANT BACKUP_ADMIN,SELECT, RELOAD, PROCESS, SUPER, LOCK TABLES, REPLICATION SLAVE, REPLICATION CLIENT, SHOW VIEW ON *.* TO 'bk_user'@'10.192.30.%'; # mkdir -p /data/backup/logs/ ; mkdir -p /data/backup/full_bak/ # 33 18 13 08 * /bin/bash /usr/local/scripts/full_xtrabackup.sh &>/dev/null . /etc/init.d/functions Date_Time=`date +%Y%m%d%H%M%S` Date_Day=`date +%Y%m%d%H%M` Target_dir="/data/backup/full_bak/" User_Name="bk_user" Pass_Word="v9SimLKsIHpwzyOgVwlM" Host_Ip="10.192.30.60" Port_MySQL="3306" Xtrabackup_Cmd="/usr/bin/xtrabackup" Compress_Threads="8" Parallel_Num='8' Use_Memory="4G" My_Conf="/data/mysql/mysql_3306/my_3306.cnf" Log_file="/data/backup/logs/" Count_Day="30" # 全备份 function Full_Backup() { "${Xtrabackup_Cmd}" --defaults-file="${My_Conf}" --host="${Host_Ip}" --user="${User_Name}" --password="${Pass_Word}" --port="${Port_MySQL}" --backup --compress --compress-threads="${Parallel_Num}" --use-memory="${Use_Memory}" --slave-info --parallel="${Parallel_Num}" --target-dir="${Target_dir}"full_bak_"${Date_Day}"/ &>>"${Log_file}""${Date_Day}".log Results=`tail -1 "${Log_file}""${Date_Day}".log | awk '{print $3}'` if [ "${Results}"x == "completed"x ]; then echo "############################################################################" &>>"${Log_file}""${Date_Day}".log action "full_backup files are successful" /bin/true &>>"${Log_file}""${Date_Day}".log else echo "############################################################################" &>>"${Log_file}""${Date_Day}".log action "full_backup files are error" /bin/false &>>"${Log_file}""${Date_Day}".log fi } function Delete_Files() { find "${Target_dir}" -type f -mtime +"${Count_Day}" -name "full_bak*" -exec rm -rf {} \; find "${Log_file}" -type f -mtime +"${Count_Day}" -name "*.log" -exec rm -rf {} \; } Full_Backup Delete_Files #################################################################################################################################################################