Windows 上的 Rsync:创建的目录权限错误
我正在尝试使用 rsync 在 Windows (cygwin) 上通过 ssh 将更改推送到我的服务器。 我正在使用的命令是:
rsync -rvz -e ssh /cygdrive/c/myfolder/ [电子邮件受保护] :/srv/www/prj112/myfolder/
/srv/www/prj112/myfolder/
归 rsyncuser
所有。我的问题是,尽管使用 rsync
子目录是在发布时创建的,但每个目录都被分配了默认权限 d---------
所以 rsync
无法复制其中的任何文件。
我该如何解决这个问题?
I'm trying to push changes to my server through ssh on windows (cygwin) using rsync
.
The command I am using is:
rsync -rvz -e ssh /cygdrive/c/myfolder/ [email protected]:/srv/www/prj112/myfolder/
/srv/www/prj112/myfolder/
is owned by rsyncuser
. My problem is that eventhough with rsync
the sub directories are create as they publish, each directory is assigned default permission of d---------
so rsync
fails to copy any files inside it.
How do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
如果您从 Windows 部署站点(例如 octopress 使用 rsync),则可以将权限设置为 775 添加多个 chmod 命令:
if you deploy a site from windows (for ex. octopress use rsync) it's possible set permission to 775 adding multiple chmod command:
要从 Windows 同步到 Unix/Linux,您应该提供类似
ssh 命令的命令,然后是
backup_excludes.txt,其中包含被忽略元素的行,例如“
然后您将在脚本中使用它”
等等。这将备份您的目录 mySensibleData、myOtherSensibleData 和 myOtherSensibleData2,目录权限为 755,文件权限为 644。您还可以在 %BACKUPLOGFILE% 中获取每个备份的备份日志。
To rsync from Windows to Unix/Linux you should provide a command like
The ssh command then is
with backup_excludes.txt containing lines of ignored elements like
Then you would use this in a script with
and so on. This will backup your directories mySensibleData, myOtherSensibleData and myOtherSensibleData2 with the permissions 755 for directories and 644 for files. You also get backup logs in your %BACKUPLOGFILE% for each backup.
当某些进程打开目标文件时,Cygwin rsync 将报告权限被拒绝。下载并运行 Process Explorer,查明是否有其他东西锁定该文件,或者尝试重命名该文件,看看是否收到有关其他进程打开该文件的 Windows 错误。
Cygwin rsync will report permission denied when some process has the target file open. Download and run Process Explorer and find out if anything else is locking the file or simply try renaming the file and see if you get the Windows error about some other process having the file open.
另外,您可以尝试创建一个(全局)环境变量
CYGWIN
并将其值设置为nontsec
Also, you can try to create a (global) environment variable
CYGWIN
and set its value tonontsec
Cygwin 1.7 版中忽略 NTFS 权限的选项已更改。这可能就是导致问题的原因。
尝试将“noacl”标志添加到 C:\cygwin\etc\fstab 中的 Cygwin 挂载中,例如:
您可以使用“chmod”选项通过 rsync 传递自定义权限:
The option to ignore NTFS permissions has changed in Cygwin version 1.7. This might be what's causing the problem.
Try adding the 'noacl' flag to your Cygwin mounts in C:\cygwin\etc\fstab, for example:
You can pass custom permissions via rsync using the 'chmod' option:
您的问题源于该目录的 Unix 权限实际上为 0。所有访问信息都存储在单独的 ACL 中,rsync 不会复制该 ACL。因此,它将远程副本的权限设置为 0,并且显然之后无法写入该目录。
运行
您可以在该目录上
,这应该可以解决您的 rsync 问题。查看联机帮助页后,我可以看出 chmod 参数自版本 ~2.6.8 起可在 rsync 中使用。但是您必须将
--chmod=ugo=rwX
与rsync -av
结合使用。您还应该尝试这个命令:
它至少可以在 Linux 上运行。请注意,rsync 不需要提及 ssh——至少在 Linux 上是这样。
但是,如果一切都失败并且只是为了提供一个选项,您可以看看这个现成的打包工具 cwRsync
Your problem stems from the fact that the Unix permissions on that directory really are 0. All of the access information is stored in separate ACLs, which rsync does not copy. Thus, it sets the permissions on the remote copy to 0, and, obviously, is unable to write to that directory afterwards.
You can run
on that directory, which should fix your rsync problem.
After a look at the manpage I can tell that the chmod param is available in rsync since version ~2.6.8. But you have to use
--chmod=ugo=rwX
in combination withrsync -av
You should also try this command:
It would work on Linux at least. And note that rsync does not need to mention ssh--at least on Linux.
But if all fails and just to give an option you may take a look at this ready packed-up tool cwRsync