`

shell 同步 learn

 
阅读更多

 

 

 

shell sync 

 

#!/bin/bash
sshpass -p 'test888' rsync -avzP -e 'ssh' /data/test/server/ms/uploadFiles/file/ root@192.168.1.30:/data/test/web/generate
if [ "$?" = '0' ];then
	echo "RSYNC 192.168.1.30 server /data/test/web/generate ...OK"
else
	dates=`date +%Y-%m-%d:%S`
	echo "RSYNC 192.168.1.30 server /data/test/web/generate ...false"
	echo "$dates Rsync fasle" > /tmp/false.txt
fi

rsync -avzP /data/test/server/ms/uploadFiles/file/ /data/test/web/generate
if [ "$?" = '0' ];then
	echo "RSYNC local server /data/test/web/generate ...OK"
else
	dates1=`date +%Y-%m-%d:%S`
	echo "$dates1 Rsync fasle" >> /tmp/false.txt
	echo "RSYNC local server /data/test/web/generate ...false"
fi

# rsync feedback
sshpass -p 'test888' rsync -avzP -e 'ssh' /data/test/server/api/upload/feedback/ root@192.168.1.30:/data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...OK"
else
	dates=`date +%Y-%m-%d:%S`
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...false"
	echo "$dates Rsync fasle" > /tmp/false.txt
fi

rsync -avzP /data/test/server/api/upload/feedback/ /data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC local server /data/test/web/generate/images ...OK"
else
	dates1=`date +%Y-%m-%d:%S`
	echo "$dates1 Rsync fasle" >> /tmp/false.txt
	echo "RSYNC local server /data/test/web/generate/images ...false"
fi

# rsync unbinding
sshpass -p 'test888' rsync -avzP -e 'ssh' /data/test/server/api/upload/unbinding/ root@192.168.1.30:/data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...OK"
else
	dates=`date +%Y-%m-%d:%S`
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...false"
	echo "$dates Rsync fasle" > /tmp/false.txt
fi

rsync -avzP /data/test/server/api/upload/unbinding/ /data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC local server /data/test/web/generate/images ...OK"
else
	dates1=`date +%Y-%m-%d:%S`
	echo "$dates1 Rsync fasle" >> /tmp/false.txt
	echo "RSYNC local server /data/test/web/generate/images ...false"
fi

# rsync upload1
sshpass -p 'test888' rsync -avzP -e 'ssh' /data/test/server/ms/plugins/ueditor/jsp/upload1/ root@192.168.1.30:/data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...OK"
else
	dates=`date +%Y-%m-%d:%S`
	echo "RSYNC 192.168.1.30 server /data/test/web/generate/images ...false"
	echo "$dates Rsync fasle" > /tmp/false.txt
fi

rsync -avzP /data/test/server/ms/plugins/ueditor/jsp/upload1/ /data/test/web/generate/images
if [ "$?" = '0' ];then
	echo "RSYNC local server /data/test/web/generate/images ...OK"
else
	dates1=`date +%Y-%m-%d:%S`
	echo "$dates1 Rsync fasle" >> /tmp/false.txt
	echo "RSYNC local server /data/test/web/generate/images ...false"
fi


# rsync images
rsync -avzP /data/test/server/api/upload/ /data/test/server/ms/api_upload
if [ "$?" = '0' ];then
	echo "RSYNC local server /data/test/web/generate ...OK"
else
	dates1=`date +%Y-%m-%d:%S`
	echo "$dates1 Rsync fasle" >> /tmp/false.txt
	echo "RSYNC local server /data/test/web/generate ...false"
fi

# rsync images
sshpass -p 'test888' rsync -avzP -e 'ssh' root@192.168.1.30:/data/test/server/api/upload/ /data/test/server/ms/api_upload 
if [ "$?" = '0' ];then
	echo "RSYNC 192.168.1.30 server /data/test/server/ms/api_upload ...OK"
else
	dates=`date +%Y-%m-%d:%S`
	echo "RSYNC 192.168.1.30 server /data/test/web/generate ...false"
	echo "$dates Rsync fasle" > /tmp/false.txt
fi

#sendmail alarm
if [ ! -f '/tmp/false' ];then
	:
else
	mail -s "Rsync data false" cong.wan@test.com < /tmp/false.txt
	rm -f /tmp/false.txt
fi

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics