例如 192.168.15.32 同步数据到 192.168.15.36
------------------server 端配置----------------------
192.168.15.36为服务端 需启动rsync服务 rsync服务启动 【 /usr/bin/rsync --daemon 】
启动前需要配置 /etc/rsyncd.conf 这个配置文件
配置文件例如
uid = root
gid = root
use chroot = no
max connections=0
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[test]
path = /home/llx/test1
comment = rsync from 192.168.15.32//如果有限定的话需要添加此句
read only = no
list = on
auth users = test
secrets file = /etc/test.pas
密码文件例如
vim /etc/test.pas
test:test test为用户 test为密码
配置结束后 要将密码文件的权限改为600 chmod 600 /etc/test.pas
----------------------client 端配置-----------------------------
192.168.13.32
设置密码文件
例如 vim /etc/test.pas
test
执行同步语句
rsync -avz --progress /home/llx/test1/ [email protected]::test/ --password-file=/etc/test.pas &
------------------有软连接的数据同步-----------------------------
在server端运行同步脚本 如: rsync -ave ssh 192.168.15.32:/home/longsl/test1/long.txt /home/longsl/test1/
------------------------------------------------------------------