标签:数据 span amp user 备份文件 ror grep fail 日志文件
#!/bin/bash
#备份文件的名字为当前主机的IP地址+tar.gz,例如172.16.103.1.tar.gz,且每次备份成功之后都会清空本地的备份目录。
#相关目录
mkdir -p /xtrabackup/mysql
back_dir="/xtrabackup/mysql"
backfilename=`ip add | grep "inet" | grep 172 |grep brd |awk -F / ‘{print $1}‘ | awk -F" " ‘{print $2}‘`
#备份数据库信息
host="127.0.0.1"
dbuser="bakuser"
dbpasswd="Admin123,."
mkdir -p ${back_dir}/log
touch ${back_dir}/log/mysql_xtraback.log
#日志文件
back_log="${back_dir}/log/mysql_xtraback.log"
innobackupex --defaults-file=/etc/my.cnf --host=${host} --user=${dbuser} --password=${dbpasswd} ${back_dir} &>> ${back_log}
if [ $? -eq 0 ]; then
echo "The backup is successful,Next step is Send to server."
tar -zcPf ${backfilename}.tar.gz ${back_dir} && scp ${backfilename}.tar.gz root@172.16.103.6:/root/${backfilename}.tar.gz
if [ $? -eq 0 ]; then
echo "Send successfully completed"
rm -rf ${back_dir}/*
if [ $? -eq 0 ]; then
echo "Cleared local backup directory"
fi
else
echo "Send failed. Check for errors"
fi
else
echo "Backup failed. Check for errors"
?
fi
标签:数据 span amp user 备份文件 ror grep fail 日志文件
原文地址:https://www.cnblogs.com/withfeel/p/11670648.html