rsync拉取模式同步文件

简介:rsync客户端拉取服务端的rsyncd配置文件进行同步,服务端的文件提供只读权限。
服务端安装rsync,使用/etc/rsyncd.conf配置文件

# /etc/rsyncd: configuration file for rsync daemon mode

# See rsyncd.conf man page for more options.

# configuration example:

uid = nobody
gid = nobody
use chroot = yes
max connections = 100

port 873
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.log
hosts allow = *

[chunk]
path = /var/public/file/chunk
comment = chunk ,rsyncd demo test!!!     
read only = no 
list = no 
ignore errors
transfer logging = no          
auth users = abc             
secrets file = /etc/rsyncd_users.db

PS:chunk是配置文件的块,abc是认证用户,rsyncd_users.db是保存认证用户和密码,都是可以自定义,

文件权限必须改为600
cat /etc/rsyncd_users.db
chmod 600 /etc/rsyncd_users.db
systemctl rstart rsyncd

abc:123456

ok,到此处,服务端的rsyncd已经配置完毕。

rsync客户端

crontab -l
*/1 * * * * /root/shell/rsync.sh > /dev/null 2>&1

cat /root/shell/rsync.sh

#!/bin/bash
#author:chunk
#date:20171010

pwd='123456'

/usr/bin/expect<<EOF
spawn  rsync -vzrtopg --progress abc@192.168.1.100::chunk  /var/www/
set timeout -1
expect {
"Password:" { send "$pwd\r" }
}
send "exit\r"
expect eof
EOF
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。