shell 同步 learn

shell sync 

#!/bin/bash
sshpass -p 'test888' rsync -avzP -e 'ssh' /data/test/server/ms/uploadFiles/file/ [email protected]:/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/ [email protected]:/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/ [email protected]:/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/ [email protected]:/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' [email protected]:/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" [email protected] < /tmp/false.txt
	rm -f /tmp/false.txt
fi

相关推荐