文章目录
1. 源目录的服务器配置
1.1 启动rsync
sudo rsync --daemon --config=/etc/rsyncd.conf # /etc/rsyncd.conf是rsync的配置文件
1.1.1 配置文件解析
#global
uid = root
gid = root
use chroot = no
max connections = 4
strict modes = yes
port = 873
pid file = /var/run/rsyncd/rsyncd.pid
motd file = /etc/rsyncd/rsyncd.motd
log file = /var/log/rsyncd/rsyncd.log
# backup一般叫做web
[backup]
# 需要同步的源目录
path = /var/www/admin.stnc.cn
ignore errors
list = yes
read only = yes
# 同步的用户名
auth users = xa
# 密码文件
secrets file = /etc/rsyncd/rsyncd.secrets
comment = xa backup dir
# 允许的ip
hosts allow = 172.16.20.1
hosts deny = *
exclude = e/
2. 目标服务器的配置
rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd/rsyncdxa.secrets xa@172.16.20.21::backup /var/www/www.stnc.cn/
# password-file为加载的密码
# xa为允许的用户名
# 172.16.20.21为源目录的服务器ip地址
# backup对应源目录的rsync配置的web
3. 错误排查
3.1 rsync error: error in socket IO (code 10) at clientserver.c(128) [Receiver=3.1.0]
错误原因:源目录服务器上rsync服务未启动
解决方法:启动源目录服务器上的rsync服务