#!/bin/bash
day=`date +%Y%m%d`
REMOTE_USER="innobackupex"
REMOTE_DIR="/fsbk/haibao_archive/innobackupex"
cat /dev/null > /tmp/innobackupex.$day.log
# 对部署的多实例数据库 进行备份 远程流数据的格式 直接通过ssh协议 备份到远程主机
# --slave-info 包含主节点 当前二进制日志文件位置 便于恢复
MYSQL_MASTER_INSTSANCE=`ls -l /etc/my330{7,8,9}.cnf | awk '{print $NF}'`
for instance in $MYSQL_MASTER_INSTSANCE
do
MYSQL_MASTER_INSTSANCE_NAME=`echo $instance | awk -F"/" '{print $3}'`
innobackupex --defaults-file=/etc/$MYSQL_MASTER_INSTSANCE_NAME --slave-info --safe-slave-backup --stream=xbstream --compress --compress-threads=4 --parallel=4 /dev/shm | ssh -i /home/$REMOTE_USER/.ssh/id_rsa $REMOTE_USER@nfsdisk-s1.haibao.com.cn cat ">" $REMOTE_DIR/$MYSQL_MASTER_INSTSANCE_NAME.$day.xbstream
if [ "$?" -eq "0" ];
then
echo "innobackupex $MYSQL_MASTER_INSTSANCE_NAME is ok." >> /tmp/innobackupex.$day.log
else
echo "innobackupex $MYSQL_MASTER_INSTSANCE_NAME is fail." >> /tmp/innobackupex.$day.log
fi
done
# 引用脚本中所定义的相关变量
. /home/haibao.scripts/sa_util/contact_email_user.sh
/usr/local/bin/sendEmail -f $smtp_user -t "$recv_user1" -cc $recv_user2 $recv_user3 -s "$smtp_host" \
-xu $smtp_user -xp $smtp_pass -o message-charset=utf8 \
-u "$HOSTNAME innobackupex log" \
-m "$HOSTNAME innobackupex log" \
-a /tmp/innobackupex.$day.log