rsync相关整理

增量同步:

flock -xn /var/run/rsync_db.lock -c '/usr/bin/rsync -avzP --delete --password-file=/etc/rsyncd/ladp.secrets  /bak/orginDir xxx@192.168.16.83::targetDir'

 

上传文件(mysqldump文件以及备份至远程服务器):

#!/bin/bash
bakdate=`date +%Y%m%d%H`
bakpath="/bak/"$bakdate
backdb=(dbname)
#mkdir directory
if [ ! -d $bakpath ]; then
    mkdir -p $bakpath
fi

for db in ${backdb[@]}
do
  bakfile=$bakpath"/"$db"."$bakdate".sql"
 /usr/bin/mysqldump  -hlocalhost -uroot -P3307 -pXXXXX --skip-lock-tables --default-character-set=utf8  $db>$bakfile
 gzip $bakfile
done
#clear 30 days ago
cldate=`date +%Y%m%d%H -d "30 days ago"`
clpath="/bak/"$cldate
#echo $clpath
if [ -d $clpath ]; then
    rm -fr $clpath
fi
flock -xn /var/run/rsync_db.lock -c '/usr/bin/rsync -rvlHpogDtS --progress --delete --password-file=/etc/rsyncd/ladp.secrets  /bak user@192.168.16.83::rsyncTarget'

 

rsync算法是为了在传输文件的同时,减少数据传输。算法核心有四块内容:

1)分块Checksum算法

2)传输算法。

3)checksum查找算法

4)比对算法

参见链接:http://coolshell.cn/articles/7425.html#more-7425

 

 

 

posted @ 2017-08-06 00:20  xjlnjut730  阅读(8)  评论(0)    收藏  举报