linux双机互备文件

只同步目录,不同步文件:

rsync -av -e "ssh -p16822" -f"+ */" -f"- *" /log/traffic_analysis_log/sys_visitlogbak/ dbmanager@DataBase-01:/log/traffic_analysis_log/

同步目录和文件:

#! /bin/sh
pathA=/log/traffic_analysis_log/visitlogbak
prefix=visitlog.2014-09-*.csv.bz2

cd $pathA
echo "cd $pathA"
fileSetA=`ls`
#fileSetA=`echo ls`
echo "files in $pathA"; echo $fileSetA
#pathB=/share/pathB/
#pathD=/share/pathD/
#cd $pathB
#echo "cd /share/pathB"
#fileSetB=`ls`
#fileSetA=`echo ls`
#echo "files in $pathB"; echo $fileSetB
echo;
echo "Now, process the files in $pathA"
for xfile in $fileSetA; do
        #cd $pathB
        if [ ! -f $xfile ]; then
                # mv $pathA/$xfile/$prefix $pathC/$xfile
                #echo "rsync $xfile $pathC"
                echo "rsync -av -e \"ssh -p 16822\" $pathA/$xfile/$prefix dbmanager@DataBase-01:/home/data/traffic_analysis_log/sys_visitlogbak/$xfile/"
                rsync -av -e 'ssh -p 16822' $pathA/$xfile/$prefix dbmanager@DataBase-01:/home/data/traffic_analysis_log/sys_visitlogbak/$xfile/
        fi
done
echo;
#echo "\nNow, process the files in $pathB"
#for xfile in $fileSetB; do
#        cd $pathA
#        if [ ! -f $xfile ]; then
#                cp $pathB/$xfile $pathD
#                echo "cp $xfile $pathD"
#        fi
#done
exit 0

笔记就这些.

 

你可能感兴趣的:(linux)