Rsync
rsync 忽略所有者、組、時間和權限
我想知道如何使用 rsync 以遞歸方式同步到文件夾,但我只需要更新新文件或更新的文件(只有內容而不是所有者、組或時間戳),並且我想刪除源中不存在的文件.
我認為您可以使用這些
-no-
選項來rsync
不複製您正在同步的文件的所有權或權限。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
可能會做您正在尋找的事情。