Rsync常見問題
用戶端待同步目錄如下:
.
`-- today
`-- subdir
`-- test-dirs
2 directories, 1 file
一、同步檔案報錯 @ERROR Unknown module test
@ERROR Unknown module test
報錯日志
@ERROR Unknown module test
rsync error:error starting client-server protocol(code 5) at main.c(1503)[sender=3.0.6]
解決辦法
在服務端配置檔案rsyncd.conf中添加如下配置:
[test]
path = /mnt/source/test
comment = web
ignore errors
read only = no
list = no
transfer logging = no
二、服務端目錄配置隻讀,無法寫入檔案
rsync -av --stats -u /home/test/ rsync://[email protected]/test --password-file=/etc/rsyncd.passwd
sending incremental file list
rsync: read error: Connection reset by peer (104)
rsync error: error in socket IO (code 10) at io.c(785) [sender=3.1.2]
解決過程
1. 在rsyncd.conf中配置rsync daemon日志檔案:
log file = /opt/var/log/rsync.log
2. 重新開機服務,
tail /opt/var/log/rsync.log
2019/05/31 03:05:49 [12180] rsync to test/ from master (11.11.11.101)
2019/05/31 03:05:49 [12180] ERROR: module is read only
2019/05/31 03:05:49 [12180] rsync error: syntax or usage error (code 1) at main.c(994) [Receiver=3.1.2]
三、服務端 today
不存在,同步 /today/subdir
下檔案報錯
today
/today/subdir
将用戶端
/home/test/today/subdir
下檔案同步到
[email protected]/test/today/subdir
rsync -av --stats -u /home/test/today/subdir/ rsync://[email protected]/test/today/subdir --password-file=/etc/rsyncd.passwd
sending incremental file list
rsync: mkdir "today/subdir" (in test) failed: No such file or directory (2)
rsync error: error in file IO (code 11) at main.c(657) [Receiver=3.1.2]
cd /home/test && rsync -avR --stats -u today/subdir rsync://[email protected]/test --password-file=/etc/rsyncd.passwd
-
使用相對路徑-R
- 自動建立
目錄,不存在的話today

-R
:不管加不加”/”,都會同相對路徑,沒有則自動建立,是以在寫指令時一定要注意。