#!/bin/bash# by glq# backup on slave,you can quickly build a slaveBklog="/root/jiankong_log/mysql3306bk.log"Bkdir=/data/backuptest -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"# tarcd $Bkdirtar -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 daysfind "$Bkdir" -name "*.tar.gz" -mtime +3 |xargs rm -f# apply-log# xtrabackup --prepare --target-dir=/data/2019*