innobackupex backup and streaming backup

innobackupex backup and streaming backup (remote backup can only be backed up locally and then passed through ssh) (it can also be backed up in mysql stop state

###########The source is fully prepared ##############
innobackupex --defaults-file=/usr/local/mysql/etc/my.cnf -- host=127.0.0.1 --port=3307 --user=root --password=****** \
--stream=xbstream --compress --compress-threads=5 . > ./bakfull_compress.xbstream
## ##############Pass to slave for decompression ##############
xbstream -x <./bakfull_compress.xbstream -C ./restore/
cd . /restore
for f in find ./ -iname "*\.qp"; do qpress -dT2 $f $(dirname $f) && rm -f $f; done############# RECOVERY DATA ###############
########### STOP mysqld process from above #######
systemctl stop mysqld3308
innobackupex --defaults-file= /usr/local/mysql3308/etc/my.cnf --use-memory=1G --apply-log ./restore
innobackupex --defaults-file=/usr/local/mysql3308/etc/my.cnf --copy- back ./restore
chown mysql:mysql -R /usr/local/mysql3308/data
systemctl restart mysqld3308
#######login into mysql########reset master;
set @@global.gtid_purged='0f07c648-618c- 11ec-ae19-5254000aa7bf:1-2207471,
1250ceb9-b976-11ec-86ee-5254000aa7bf:1-20, 2133c30c-b977-11ec
-a0e9-5254000aa7bf:1-5,
7e5451a e-b977-11ec-94ef-5254000aa7bf:1-
## ###
  _
  _
  _
  _
  _
_
 
_ ################################# (compression will consume time and cause backup time to increase) ######## #######################################
#innobackup local backup and compressed by gzip
innobackupex --defaults-file=/etc/my.cnf --host=192.168.100.96 --port=3306 --user=root --password=skyvis_mysql --stream=tar /temp | gzip > ./backup.tar .gz
#innobackup local backup and compressed by compress (generate qp file)
innobackupex --defaults-file=/etc/my.cnf --host=192.168.100.96 --port=3306 --user=root --password=skyvis_mysql --compress /temp

#Stream backup---Back up to the remote through ssh, compress through gzip or --compress
innobackupex --defaults-file=/etc/my.cnf --host=192.168.100.96 --port=3306 --user =root --password=skyvis_mysql --stream=tar /temp | ssh [email protected] "gzip -> /data1/backup_mysql.tar.gz"
innobackupex --defaults-file=/etc/my.cnf --host =192.168.100.96 --port=3306 --user=root --password=skyvis_mysql --stream=xbstream --compress /temp | ssh [email protected] "cat -> /data1/backup_mysql.xbstream"

#1 Use xbstream to expand the xbstream file
xbstream -x < ./backup_mysql.xbstream -C ./shou
#2--decompress to decompress the qp file, --remove-original delete the qp file after decompressing the qp file. The system needs to install the qpress software
innobackupex --decompress --remove-original $(pwd)

#Streaming backup---Backup to the remote through ssh, no compression (need to specify --stream)
innobackupex --defaults-file=/etc/my.cnf --host=192.168.100.96 --port=3306 - -user=root --password=skyvis_mysql --stream=tar /temp | ssh [email protected] "cat -> /data1/backup_mysql.tar"
################# #################################################### ###############

#Make the first full backup
[root@shou ~]#innobackupex --defaults-file=/usr/local/mysql/etc/my.cnf --host=127.0.0.1 --port=3306 --user=root --password=skyvis_mysql ./restor

#Make the first backup, based on the last full backup
[root@shou ~]#innobackupex ---defaults-file=/usr/local/mysql/etc/my.cnf --host=127.0.0.1 -- port=3306 --user=root --password=skyvis_mysql --incremental ./restore/incer1 --incremental-basedir=./restore/2022-04-23_11-39-31

#Make the second full backup, based on the first backup
[root@shou ~]#innobackupex ---defaults-file=/usr/local/mysql/etc/my.cnf --host=127.0.0.1 -- port=3306 --user=root --password=skyvis_mysql --incremental ./restore/incer2 --incremental-basedir=./restore/incer1/2022-04-23_11-47-10

########################### Data integration during recovery ##################### ####################################

# Apply logs to the integrated starting backup set—full backup set, and specify "--redo-only" to start adding
innobackupex --apply-log --use-memory=1G --redo-only ./restore /2022-04-23_11-39-31/

# "Prepare" the first backup set and append it to the full backup set
innobackupex --apply-log --use-memory=1G --redo-only ./restore/2022-04-23_11-39- 31/ --incremental-dir=./restore/incer1/2022-04-23_11-47-10/

# "Prepare" the second additional backup set and append it to the full backup set, but no longer apply "--redo-only", indicating the end point of integration. If this option is accidentally added, the effect is not significant, and the server will perform a rollback phase.
innobackupex --apply-log --use-memory=1G ./restore/2022-04-23_11-39-31/ --incremental-dir=./restore/incer2/2022-04-23_11-53-19/

# Perform an overall "preparation" for the integrated full backup set (if --redo-only was added in the previous step, this step will also be rolled back.)
innobackupex --apply-log --use-memory=1G . /restore/2022-04-23_11-39-31/

####################Recover data ############################ ##
innobackupex --defaults-file=/usr/local/mysql3308/etc/my.cnf --copy-back ./restore/2022-04-23_11-39-31/

###############Modify the owner and group and start mysqld3308############
chown mysql:mysql -R /usr/local/mysql3308/data && systemctl start mysqld3308

#The recovery steps given in the official document:
innobackupex --apply-log --redo-only BASE-DIR
innobackupex --apply-log --redo-only BASE-DIR --incremental-dir=INCREMENTAL-DIR-1
innobackupex - -apply-log BASE-DIR --incremental-dir=INCREMENTAL-DIR-2
innobackupex --apply-log BASE-DIR
innobackupex --copy-back BASE-DIR
-------------- ---------------------
 

Guess you like

Origin blog.csdn.net/eagle89/article/details/130229212