
ソースファイルには次の権限があります。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