rsyncは所有者とグループを上書きし続けます。

rsyncは所有者とグループを上書きし続けます。

ソースファイルには次の権限があります。jim:jim

ソース宛先ファイルには、次の権限があります。www-data:www-data

私のコマンド:rsync -Pav --no-p --no-o --no-g file ubuntu@ip_address:/path/file

ただし、ターゲットファイルはubuntu:ubuntu次のようになります。www-data:www-data

ただし、ソースファイルとターゲットファイルが異なる場合でも、権限は保持されます。何が問題なのでしょうか?

ノート:rsyncはMacOS上でUbuntuとして実行されます。これが関連性があるかどうかはわかりません。

ありがとうございます。

答え1

あなたのターゲットユーザーアカウントには、ubuntu自分が所有するファイルを作成する権限がないため、目的のwww-data効果を得ることはできません。

ターゲットユーザー名またはwww-dataを使用するrootか、バックアップ専用の場合は-M--fake-superコマンドに追加することを検討してください。

答え2

あなたはそれを維持したいと言ったが、それをオフにすることをwww-data:www-data指定しました:--no-o --no-g

   --owner, -o
          This option causes rsync to set the owner of the destination file to 
          be the same as the source file, but only if the receiving rsync is  
          being  run  as the super-user (see also the --super and --fake-super
          options).  Without this option, the owner of new and/or transferred 
          files are set to the invoking user on the receiving side.

(団体も同様)

これを行うには、リモートホストでもルートである必要があります。次のコマンドを使用してこれを実行できます(sudoリモートシステムで使用している場合NOPASSWD)。

rsync -Pav --rsync-path="sudo rsync" file ubuntu@ip_address:/path/file

関連情報