使用xtrabackup物理备份mysql8.0

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

#!/bin/bash
# by glq
# backup on slave,you can quickly build a slave

Bklog="/root/jiankong_log/mysql3306bk.log"
Bkdir=/data/backup

test -d "$Bkdir" || mkdir -p "$Bkdir"

# all backup
/usr/bin/xtrabackup  --defaults-file=/etc/3306.cnf --login-path=root3306 --backup --slave-info --target-dir="$Bkdir"/`date --date 'today' +%Y-%m-%d_%H-%M-%S` 2>"$Bklog"
echo "============== total take $SECONDS seconds to backup ! ================"  >> "$Bklog"
# tar
cd $Bkdir
tar -czvf full_3306.`ls -l|grep ^d|tail -n 1 | awk '{print $NF}'`.tar.gz -c `ls -l|grep ^d|tail -n 1 | awk '{print $NF}'` --remove-files
# keep 3 days
find "$Bkdir" -name "*.tar.gz" -mtime +3 |xargs rm -f
# apply-log
# xtrabackup --prepare --target-dir=/data/2019*

 

转载于:https://my.oschina.net/longquan/blog/497257

你可能感兴趣的:(使用xtrabackup物理备份mysql8.0)