1.wget
2.tar zxvf rsync-3.0.5.tar.gz
cd rsync-3.0.5
./configure ;make;make install
配置server端
3.编辑/etc/rsyncd.conf文件
vi /etc/rsyncd.conf
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
[test] #这里是认证的模块名,在client端需要指定
path = /usr/local/squid-27/var/logs/ #需要做镜像或同步的目录
comment = test folder
uid = nobody
gid = nobody
ignore errors # 可以忽略一些无关的IO错误
read only = yes
list = no
secrets file = /etc/rsyncd.secrets # 认证文件名
4.vi /etc/rsyncd.secrets #在server端生成一个密码文件
test:test123
5.rsync --daemon --config=/etc/rsyncd.conf #在server端将rsync以守护进程形式启动
客户端
6.配置密码文件:
vi /etc/rsyncd.secrets
test:test123
7.设置rsyncd文件
#!/bin/bash
squids[0]="192.168.31.136"
squids[0]="192.168.31.16"
DESTDIR=/home
for squid in ${squids[*]}
do
if [ ! -e $DESTDIR/$squid ]
then
mkdir $DESTDIR/$squid
fi
datedir=$(date +%Y%m%d)
# now the actual transfer
if [ ! -e $DESTDIR/$squid/$datedir ]
then
mkdir $DESTDIR/$squid/$datedir
fi
if ping -c4 $squid > /dev/null ;then
rsync -tvzrp --progress --delete --password-file=/etc/rsyncd.secrets
$DESTDIR/$squid/$datedir
else
echo network failer
exit 1
fi
done
8.写入计划任务
5 0 * * * /etc/init.d/rsyncd
阅读(1154) | 评论(0) | 转发(0) |