# 部分参数请根据实际调整
current time=$(date +"%Y-%m-%d %H-%M-%S")
remote backup_dir="/data/backup file storage/mysql/hesuan/$[current time] full"
sshpass -p "xxx" ssh xxx"mkdir -p $(remote backup dir)"
user=root
password=xxxx
socket="/data/mysq1/3396/aata/sock/mysgl.sock"
myconf="/data/mysql/3306/conf/my.cnf"
hub ssh user passwd="xxxxx"
expect <<EOF
set timeout 1200;
spawn bash -c "/usr/local/xtrabackup/bin/xtrabackup --defaults-file=$(myconf) \
--no-timestamp --slave-info \
--paralle1=8 --compress --compress-thread=8 \
--safe-slave-backup --safe-slave-backup-timeout=360 \
--ftwrl-wait-threshold=10 --ftwrl-wait-query-type=all --ftwrl-wait-timeout=180 \
--kill-long-queries-timeout=40 --kill-long-query-type=SELECT \
--user=${user] --password=${password} --socket=${socket} \
--backup
--stream=xbstream \
--target-dir=./ | ssh xxxxx \"cat- >$(remote backup dir}/$(date +%Y-%m-%d %H:%m:%s) fullback.xbstream \""
expect {
"*yes/no*" {send "yes\n";exp continue}
"*permission denied*" (exit 1}
"*password*" {send "${hub ssh user_passwd]\n";exp continue}
"*Killed by signal 1" {exit 1}
}
EOF
0 评论