我将 rsyncd 作为 Windows 服务运行,但当我尝试访问模块并从中同步时,我得到了我想要的文件,以及很多我不想要的文件 — 因为它们不在远程端的模块中。为了测试,我只将一个名为“the_only_file”的文件放在备份文件夹中。从我的本地机器:
username@local:~$ rsync username@remote::backup .
receiving incremental file list
file has vanished: "/proc" (in backup)
file has vanished: "/cygdrive/c" (in backup)
file has vanished: "/cygdrive/d" (in backup)
skipping non-regular file "dev/clipboard"
skipping non-regular file "dev/conin"
skipping non-regular file "dev/conout"
skipping non-regular file "dev/console"
skipping non-regular file "dev/dsp"
skipping non-regular file "dev/full"
skipping non-regular file "dev/kmsg"
skipping non-regular file "dev/null"
skipping non-regular file "dev/ptmx"
skipping non-regular file "dev/pty0"
skipping non-regular file "dev/random"
skipping non-regular file "dev/scd0"
skipping non-regular file "dev/sda"
skipping non-regular file "dev/sda1"
skipping non-regular file "dev/sda2"
skipping non-regular file "dev/sr0"
skipping non-regular file "dev/tty"
skipping non-regular file "dev/urandom"
skipping non-regular file "dev/windows"
skipping non-regular file "dev/zero"
./
the_only_file
cygdrive/
dev/
sent 70 bytes received 613 bytes 455.33 bytes/sec
total size is 0 speedup is 0.00
rsync warning: some files vanished before they could be transferred (code 24) at main.c(1708) [generator=3.1.0]
username@local:~$ ls
cygdrive dev the_only_file
我在 cygwin 中使用以下命令来创建服务:
cygrunsrv --install "rsyncd" --path "$(which rsync)" --args "--daemon --no-detach" --desc "Starts rsync daemon to accept rsync connections" --disp "rsync daemon" --type "auto"
我的 rsyncd.conf 非常简单:
chroot = yes
charset = UTF-8
log file = /var/log/rsyncd.log
[backup]
uid = username
secrets file = /cygdrive/c/cygwin/etc/rsyncd.secrets
auth users = username
path = /cygdrive/c/Users/username/backup
list = false
readonly = false
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz *.7z
我该怎么做才能让 Cygwin 的 rsyncd 表现得像它应该的那样?(为什么它会尝试向我发送 /proc 目录?真奇怪……)
答案1
我通过一种我不想做的方式来“解决”了这个问题:我在 rsyncd.conf 中添加了以下行:
exclude from = /cygdrive/c/cygwin/etc/rsyncd.exclude
并且 rsyncd.exclude 是:
- /dev/*
- /dev
- /cygdrive/*
- /cygdrive
- /proc
现在它可以按预期工作了,但需要注意的是,这意味着我不能在共享的根目录中拥有名为“dev”、“proc”或“cygdrive”的目录/文件。对大多数人来说可能并不重要;拥有“cygdrive”或“proc”文件夹会令人困惑,但可以说,devs 的文件夹应该被称为“dev”或类似的名称。同样,这似乎有点微不足道,也许大多数人不会在意。
答案2
我通过添加use chroot = false
来解决这个问题/etc/rsyncd.conf
。