Rsync 未正确设置 Windows 文件夹的权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6649527/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 17:23:18  来源:igfitidea点击:

Rsync does not properly set permissions on Windows folder

windowsrsyncdirectory-permissions

提问by Michael

I'm using rsync on Windows 7 (in particular, cwrsync). I'm using a simple command as such:

我在 Windows 7 上使用 rsync(特别是 cwrsync)。我正在使用一个简单的命令:

rsync -r --perms --delete /cygdrive/c/Users/Michael/Documents/Personal/ /cygdrive/c/Users/Michael/Documents/Personal_Backup/

The recursive copy works fine, except if I was to (right-click/Properties/Security tab) on any folder created by rsync on the destination; I get the following pop-up message:

递归复制工作正常,除非我要(右键单击/属性/安全选项卡)在目标上由 rsync 创建的任何文件夹上;我收到以下弹出消息:

The permissions on {folderName} are incorrectly ordered, which may cause some entries to be ineffective.

{folderName} 的权限排序不正确,可能会导致某些条目无效。

I also tried the --acls option but get the following error:

我也尝试了 --acls 选项,但收到以下错误:

recv_acl_access: value out of range: ff rsync error: error in rsync protocol data stream (code 12) at acls.c(690) [Receiver=3.0. rsync: connection unexpectedly closed (9 bytes received so far) [sender] rsync error: error in rsync protocol data stream (code 12) at io.c(610) [sender=3.0.8]

recv_acl_access:值超出范围:ff rsync 错误:acls.c(690) [Receiver=3.0. rsync:连接意外关闭(到目前为止已收到 9 个字节)[sender] rsync 错误:io.c(610) 处的 rsync 协议数据流(代码 12)中的错误 [sender=3.0.8]

In any case, I just want to use rsync correctly so that viewing the Security permissions in Windows won't throw an error.

无论如何,我只想正确使用 rsync 以便在 Windows 中查看安全权限不会引发错误。

回答by bizna

Michael,

迈克尔,

This solutionsuggests that you should not be using --perms, but using --chmod=ugo=rwXinstead.

此解决方案建议您不应使用--perms,而应使用--chmod=ugo=rwX

Good luck!

祝你好运!

Dotan

刀坦

回答by JosiahYoder-deactive except..

I use the now-deprecated cacls to add myself back in after the copy occurs.

我使用现已弃用的 cacls 在复制发生后重新添加自己。

rsync -avASPC sourceDir/* destDir
cacls destDir /t /e /r doej
cacls destDir /t /e /g doej:f

Where sourceDir is the source directory and destDir is the destination directory and doej is the username. It would probably be better to use icacls, but I haven't learned it yet.

其中 sourceDir 是源目录,destDir 是目标目录,doej 是用户名。使用 icacls 可能会更好,但我还没有学会它。

I also tried robocopy, but I did not have the permissions I needed to make that work, it seems.

我也尝试过 robocopy,但我似乎没有完成这项工作所需的权限。

Flags used for rsync

用于 rsync 的标志

 -a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
    -r, --recursive             recurse into directories
    -l, --links                 copy symlinks as symlinks
    -p, --perms                 preserve permissions
    -t, --times                 preserve modification times
    -g, --group                 preserve group
    -o, --owner                 preserve owner (super-user only)
    -D                          same as --devices --specials
       --devices               preserve device files (super-user only)
       --specials              preserve special files
 -v, --verbose               increase verbosity
 -S, --sparse                handle sparse files efficiently
 -A, --acls                  preserve ACLs (implies -p, which is also implied by -a)
 -P                          same as --partial --progress
    --progress              show progress during transfer
    --partial               keep partially transferred files
 -C, --cvs-exclude           auto-ignore files in the same way CVS does

Flags used from CACLS

CACLS 中使用的标志

  /T            Changes ACLs of specified files in
  /E            Edit ACL instead of replacing it.
  /R user       Revoke specified user's access rights (only valid with /E).
  /P user:perm  Replace specified user's access rights.
                Perm can be: ...
                           F  Full control

回答by dzhi

One word, Robocopy.

一个字,的Robocopy

I had exactly the same isues with borked permissions while using cwRsync, tried numerous things but none seemed to work so I gave up eventually.

我在使用 cwRsync 时遇到了完全相同的权限问题,尝试了很多东西,但似乎都没有奏效,所以我最终放弃了。

This is default Windows tool and has similar (for your purpose, the same) feature set.

这是默认的 Windows 工具,具有类似(出于您的目的,相同)功能集。

I discovered it last night and ditched rsync completely. It's built for unix-like's so some sort of bummer is expected on Windows.

我昨晚发现了它并完全放弃了 rsync。它是为类 Unix 系统构建的,因此在 Windows 上预计会有一些令人失望的事情。

This got me started:

这让我开始:

http://www.sevenforums.com/tutorials/187346-robocopy-create-backup-script.html

http://www.sevenforums.com/tutorials/187346-robocopy-create-backup-script.html

Here's the little backup scriptI made for myself to mirror my partitions to external drive.

这是我为自己制作的用于将分区镜像到外部驱动器的小备份脚本

Don't look back for rsync any more.

不要再回头找 rsync 了。