Answers:
我想你可以使用-no-
选项rsync
来不复制你的同步中文件的所有权或权限。
--no-OPTION
You may turn off one or more implied options by prefixing the option
name with "no-". Not all options may be pre‐fixed with a "no-":
only options that are implied by other options (e.g. --no-D,
--no-perms) or have different defaults in various circumstances (e.g.
--no-whole-file, --no-blocking-io, --no-dirs). You may specify
either the short or the long option name after the "no-" prefix (e.g.
--no-R is the same as --no-relative).
For example: if you want to use -a (--archive) but don’t want -o
(--owner), instead of converting -a into -rlptgD, you could specify
-a --no-o (or -a --no-owner).
The order of the options is important: if you specify --no-r -a, the
-r option would end up being turned on, the opposite of -a
--no-r. Note also that the side-effects of the --files-from
option are NOT positional, as it affects the default state of several
options and slightly changes the meaning of -a (see the --files-from
option for more details).
翻阅手册页,我相信您会想使用以下代码:
$ rsync -avz --no-perms --no-owner --no-group ...
要删除不存在的文件,可以使用--delete
开关:
$ rsync -avz --no-perms --no-owner --no-group --delete ....
至于时间戳,我没有找到一种方法来保留此时间戳而不更改您对SOURCE与DEST文件进行比较的方式。您可能想rsync
使用此开关告诉忽略时间戳记:
-I, --ignore-times
Normally rsync will skip any files that are already the same size
and have the same modification timestamp. This option turns off this
"quick check" behavior, causing all files to be updated.
对于时间戳,--no-times
可能会做您想要的。
我认为您正在寻找的是选项
rsync -r --size-only
从手册页:
--size-only
This modifies rsync’s "quick check" algorithm for finding files that need to be transferred,
changing it from the default of transferring files with either a changed size or a changed
last-modified time to just looking for files that have changed in size. This is useful when
starting to use rsync after using another mirroring system which may not preserve timestamps
exactly.
如果您确实要删除源目录中缺少的文件,请使用 --delete
您可以强制rsync忽略基于文件mod时间和大小的检查,并通过“ -c”开关使用基于chksum的方法。
-c, --checksum skip based on checksum, not mod-time & size
这确实意味着它需要以块为单位比较整个文件(并在源和目标之间来回传输相关元数据以实现此目的),而不管文件时间和大小是否匹配,而仅传输不同的块在源和目标之间。
将此开关与其他人建议的其他开关结合使用,应该会限制复制的内容(仅复制已更改的内容),并具有在源和目标之间进行一致性检查的优势,但是根据链接速度的不同,它花费的时间会更长。它必须在文件的两面都进行chksum并进行比较)。
>f..T...
,这表明在目标上设置了文件标志和修改时间,这是我要避免的事情。