rsync 是一个Unix系统下的文件同步和传输工具
rsync默认的配置文件在/etc/rsyncd.conf

一个实例文件:

 

motd file=/etc/motd

max connections = 10

syslog facility=local3

log file = /opt/log/rsync

 

[nginxlog]
        comment = nginxlog
        path = /opt/log/nginxlog
        read only = yes
        list = yes
        uid = nobody
        gid = nobody
[log]
    comment = log
    path = /maildata/uploadlog
    read only = no
    list = no
    auth users = loguser
    secrets file = /etc/rsyncd/rsyncd.secrets

编辑密钥文件:

vi /etc/rsyncd/rsyncd.secrets

ysz:password

修改密钥文件的权限

chmod 600 /etc/rsyncd/rsyncd.secrets

注意的是,如果uid是nobody,可能会遇到权限的错误

 
“failed: Permission denied (13)”


此时,需要把对应的path目录的权限给改成777

启动rsync服务
/usr/bin/rsync --daemon

rsync上传文件:
rsync -vp ysz.log 192.168.95.180::nginxlog
rsync取远端的文件:
rsync --progress 192.168.95.180::nginxlog/nginx_access_vipwap.log .


带密钥认证的访问:

/usr/bin/rsync -vzrtopg --progress --password-file=/opt/ysz/rsync.secrets ysz@1.1.1.110::blog/* .