Windows 上的 Rsync:创建的目录权限错误

发布于 2024-11-04 00:08:55 字数 524 浏览 1 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

烟花易冷人易散 2024-11-11 00:08:56

如果您从 Windows 部署站点(例如 octopress 使用 rsync),则可以将权限设置为 775 添加多个 chmod 命令:

   rsync -avz --chmod=ug=rwx --chmod=o=rx -e ssh

if you deploy a site from windows (for ex. octopress use rsync) it's possible set permission to 775 adding multiple chmod command:

   rsync -avz --chmod=ug=rwx --chmod=o=rx -e ssh
鲜血染红嫁衣 2024-11-11 00:08:56

要从 Windows 同步到 Unix/Linux,您应该提供类似

SET BACKUP_SERVER=my.backup.server
SET SSH_USER=theUnixUserName
SET STORAGEPATH=/home/%SSH_USER%/Backup/
SET STORAGEURI=%BACKUP_SERVER%:%STORAGEPATH%    
SET SSH_ID=/cygdrive/c/Users/theWindowsUserName/Documents/keyfiles/id_dsa
SET EXCLUDEFILE=backup_excludes.txt
SET BACKUPLOGFILE=/cygdrive/c/Users/theWindowsUserName/Backuplogs/backup-%DATE%-%TIME::=-%.log

ssh 命令的命令,然后是

SET BACKUP=rsync -azvu --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --rsh="ssh -l %SSH_USER% -i '%SSH_ID%'" --exclude-from=%EXCLUDEFILE% --delete --delete-excluded --log-file="%BACKUPLOGFILE%"

backup_excludes.txt,其中包含被忽略元素的行,例如“

.git
.svn
.o
\Debug
\Release

然后您将在脚本中使用它”

%BACKUP% /cygdrive/c/mySensibleData %STORAGEURI%
%BACKUP% /cygdrive/c/myOtherSensibleData %STORAGEURI%
%BACKUP% /cygdrive/c/myOtherSensibleData2 %STORAGEURI%

等等。这将备份您的目录 mySensibleDatamyOtherSensibleDatamyOtherSensibleData2,目录权限为 755,文件权限为 644。您还可以在 %BACKUPLOGFILE% 中获取每个备份的备份日志。

To rsync from Windows to Unix/Linux you should provide a command like

SET BACKUP_SERVER=my.backup.server
SET SSH_USER=theUnixUserName
SET STORAGEPATH=/home/%SSH_USER%/Backup/
SET STORAGEURI=%BACKUP_SERVER%:%STORAGEPATH%    
SET SSH_ID=/cygdrive/c/Users/theWindowsUserName/Documents/keyfiles/id_dsa
SET EXCLUDEFILE=backup_excludes.txt
SET BACKUPLOGFILE=/cygdrive/c/Users/theWindowsUserName/Backuplogs/backup-%DATE%-%TIME::=-%.log

The ssh command then is

SET BACKUP=rsync -azvu --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --rsh="ssh -l %SSH_USER% -i '%SSH_ID%'" --exclude-from=%EXCLUDEFILE% --delete --delete-excluded --log-file="%BACKUPLOGFILE%"

with backup_excludes.txt containing lines of ignored elements like

.git
.svn
.o
\Debug
\Release

Then you would use this in a script with

%BACKUP% /cygdrive/c/mySensibleData %STORAGEURI%
%BACKUP% /cygdrive/c/myOtherSensibleData %STORAGEURI%
%BACKUP% /cygdrive/c/myOtherSensibleData2 %STORAGEURI%

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.

清君侧 2024-11-11 00:08:56

当某些进程打开目标文件时,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.

半暖夏伤 2024-11-11 00:08:56

另外,您可以尝试创建一个(全局)环境变量 CYGWIN 并将其值设置为 nontsec

Also, you can try to create a (global) environment variable CYGWIN and set its value to nontsec

深居我梦 2024-11-11 00:08:55

Cygwin 1.7 版中忽略 NTFS 权限的选项已更改。这可能就是导致问题的原因。

尝试将“noacl”标志添加到 C:\cygwin\etc\fstab 中的 Cygwin 挂载中,例如:

none /cygdrive cygdrive user,noacl,posix=0 0 0

您可以使用“chmod”选项通过 rsync 传递自定义权限:

rsync -rvz --chmod=ugo=rwX -e ssh source destination

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:

none /cygdrive cygdrive user,noacl,posix=0 0 0

You can pass custom permissions via rsync using the 'chmod' option:

rsync -rvz --chmod=ugo=rwX -e ssh source destination
坦然微笑 2024-11-11 00:08:55

您的问题源于该目录的 Unix 权限实际上为 0。所有访问信息都存储在单独的 ACL 中,rsync 不会复制该 ACL。因此,它将远程副本的权限设置为 0,并且显然之后无法写入该目录。
运行

chmod -R 775

您可以在该目录上

,这应该可以解决您的 rsync 问题。查看联机帮助页后,我可以看出 chmod 参数自版本 ~2.6.8 起可在 rsync 中使用。但是您必须将 --chmod=ugo=rwXrsync -av 结合使用。

您还应该尝试这个命令:

rsync -av <SOURCE_DIR> [email protected]:/srv/www/prj112/myfolder

它至少可以在 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

chmod -R 775

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 with rsync -av

You should also try this command:

rsync -av <SOURCE_DIR> [email protected]:/srv/www/prj112/myfolder

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文