rsyncを使用してフォルダに再帰的に同期する方法を知りたいのですが、新しいファイルまたは更新されたファイルのみを更新するだけで(所有者、グループ、またはタイムスタンプではないコンテンツのみ)、ソースに存在しないファイルを削除したいと思います。
ベストアンサー1
-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 ....
タイムスタンプ
タイムスタンプの場合、ソースファイルをターゲットファイルと比較する方法を変更せずに保存する方法はありません。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
必要な操作を実行できます。