我在 Windows 上使用 rsync 和 cygwin 通过 ssh 将文件从 Windows 盒子传输到 Ubuntu 盒子时遇到问题。文件传输开始,但服务器端新创建的目录和文件总是在没有用户权限的情况下创建。因此,任何进一步写入目录或子目录的尝试都会从 rsync 中返回众多“权限被拒绝 (13)”错误之一。我应该使用什么正确的语法?我需要有一个更明确的 rsyncd.conf 文件吗?
在 Windows 端,我发出以下命令:
Patrick@ELWAH P:\Music
> rsync -avz --progress -h ./iTunes [email protected]:/mnt/largemarge
在服务器端,它创建具有如下权限的目录:
patrick@Ceres:/mnt/largemarge$ ll
total 12
drwxr-xr-x 3 patrick patrick 4096 Jul 1 22:16 ./
drwxr-xr-x 3 root root 4096 Jul 1 20:23 ../
d---rwx--- 5 patrick patrick 4096 Jul 1 21:52 iTunes/
patrick@Ceres:/mnt/largemarge$
Windows 的输出最终会产生如下错误:
Patrick@ELWAH P:\Music
> rsync -avz --progress -h ./iTunes [email protected]:/mnt/largemarge
[email protected]'s password:
sending incremental file list
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/Album Artwork/Cache" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
iTunes/Album Artwork/
iTunes/Album Artwork/Cache/
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/Album Artwork/Cloud Purchases" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
iTunes/Album Artwork/Cloud Purchases/
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/Album Artwork/Download" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
iTunes/Album Artwork/Download/
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/Album Artwork/Remote" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/Previous iTunes Libraries" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
rsync: recv_generator: mkdir "/mnt/largemarge/iTunes/iTunes Media" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
iTunes/Album Artwork/Remote/
iTunes/Previous iTunes Libraries/
iTunes/iTunes Media/
sent 2.10M bytes received 13.33K bytes 103.31K bytes/sec
total size is 332.36G speedup is 156,927.14
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1165) [sender=3.1.1]
答案1
rsync
的-a
选项实际上是(根据手册页)的别名-rlptgoD
。该-p
列表中的用于“保留权限”;即,rsync 将对stat()
源文件执行操作并将权限位复制到目标文件。
由于 Windows 没有任何 unix 权限,因此 cygwin 必须得出一个近似值,这必然是有一定限制的。如果你只是不要求rsync
复制权限,它将创建具有默认权限位的文件和目录,并且该问题不应该存在。
请注意,-g
和-o
分别代表“保留组”和“保留所有者”,出于类似的原因,您可能也希望将其排除。
因此,您的整个命令将变为:
rsync -rltvzD --progress -h <source> <destination>