mysql-binlog server的实现

脚本:

#!/bin/sh
source $1
cd $BACKDIR
echo "Backup dir: $BACKDIR"
while:
do
LASTFILE=`ls $BACKDIR | grep -v orig | tail -n 1`
TIMESTAMP=`date +%Y%m%d%H%M%S`
SIZE=$(stat -c%s "$LASTFILE")
if[ $SIZE -gt 0 ];then
echo -e "\033[31mBacking up last binlog...\033[0m"
mv $LASTFILE $LASTFILE.orig$TIMESTAMP
fi
touch $LASTFILE
echo -e "\033[32mstart living binlog backup...\033[0m"
$MBL --raw --read-from-remote-server --stop-never --host $HOST -u $USER -p $PASS $LASTFILE
echo -e "\033[31mmysqlbinlog exit with $? trying to reconnect server in $RETRY seconds\033[0m"
sleep 10
done

配置文件:

MBL=/usr/local/mysql/bin/mysqlbinlog
HOST=192.168.2.100
USER=repl
PASS=Fuck@anquan1.com
BACKDIR=/logs/binlog_back/tmsdb
RETRY=10

启动:

sh script_name conf_name 

mysql-binlog server的实现

上一篇:mysqldump跨实例备份到远程主机


下一篇:MySQL单行长度限制问题