rsync同步故障处理脚本

rsync同步故障(win08--->ubuntu12.04)

源数据服务器为windows2008,安装cwRsyncServer,经常性同步过程卡死不退出,一下脚本用以解决此问题


#!/bin/bash

PRI=/root/rsync.pwd

IST=/root/ign.list

SF=root@223.*.*.*::test

DT=/var/www

LOG=/var/log/cdhome_rsync.log

PID=/tmp/cdhome_rsync.pid

FI=/tmp/cdh_test

DATE="date +%Y-%m-%d~%k:%M:%S"

SYNC="/usr/bin/rsync -vuzrtogp --bwlimit=512 --port=8073"


[ ! -f "$FI" ] && /usr/bin/touch $FI


CDH_SYNC(){

echo $$ > $PID

$SYNC --exclude-from=$IST --password-file=$PRI $SF $DT

echo "`$DATE` sync ok" >> $LOG

rm -rf $PID

exit 0

}


if [ ! -f "$PID" ] ;then

echo $$ > $PID

CDH_SYNC

fi


TID=`cat $PID`

LID=`ps aux|grep $TID|grep -v grep`

[ -z "$LID" ] && CDH_SYNC

ZID=`cat $FI`

if [[ -n "$LID" && -n "$ZID" ]];then

kill -9 $TID

/usr/bin/killall rsync &> /dev/null

ARD=(`ps -C rsync|awk '{print $1}'|grep -v PID`)

for d in ${ARD[@]};do

[ -z $d ] && continue

if ps aux|grep $d|grep -v grep ;then

kill -9 $d

fi

done

echo $$ > $PID

rm -rf $FI

CDH_SYNC

fi

[ -n "$LID" ] && echo 1 > $FI && echo "`$DATE` --> Warning!!! <-- " >> $LOG && exit 0


你可能感兴趣的:(rsync,cwRsyncServer)