Rsyncコマンドの問題、所有者とグループのアクセス許可は変更されません


28

経由で所有者とグループを設定しようrsyncとしていますが、機能していないようです。

これはコマンドです:

sudo rsync -rlptDvz --owner=cmsseren --group=cmsseren /home/serena/public_html/ -e ssh root@ip:/home/cmsseren/public_html2/

ファイルは正しく同期されますが、所有者とグループは変更されていないようです。

回答:


14

正常に動作しているようです。--ownerおよび--groupを使用して、所有者名とグループ名を保持します(設定しません)...転送後に変更したくないことを意味します。

これらのオプションを使用しない場合、ユーザーとグループは受信側の呼び出しユーザーに変更されます。他のユーザーを指定する場合はchown、スクリプトにコマンドを追加する必要があります。

-o, --owner
    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...

-g, --group
    This option causes rsync to set the group of the destination file to be the same as 
    the source file. If the receiving program is not running as the super-user (or if
    --no-super was specified), only groups that the invoking user on the receiving side
    is a member of will be preserved. Without this option, the group is set to the default
    group of the invoking user on the receiving side...

男rsync


1
それでは、どのようにしてユーザーとグループをリモートでチャウンできますか?ssh経由?方法を教えてください。両方のサーバーにルートアクセス権があります。私はsshキーを使いたくありませんが、あなたが知っているすべてのオプションを教えてください、私はそれを感謝します。迅速な対応をありがとう
アーノルドバザルドゥア

:コマンドは次のようなものになります ssh root@ip 'chown -R cmsseren:cmsseren /home/serena/public_html2/*'
user3150166

試しましたが、うまくいきませんでした。所有者とユーザーは同じです。コマンドを実行した後、次のように表示されます
。stdin

現在、ファイアウォールの問題が機能しています。今、私はsshとrsyncのパスワード入力を自動化する必要があります
Arnoldo Bazaldua 14年

あなたの助けに感謝、otherquestionでこれを投稿する-私
アーノルドBazaldua

61

rsyncのバージョン3.1.0では、Thomasが導入--usermapおよび--groupmap言及され--chownていますが、シナリオに適した便利なオプションも導入されています。

--chown=USER:GROUP
    This option forces all files to be owned by USER with group GROUP.
    This  is  a  simpler  interface  than  using  --usermap  and  --groupmap directly,
    but  it  is implemented using those options internally, so you cannot mix them.
    If either the USER or GROUP is empty, no mapping for the omitted user/group will
    occur.  If GROUP is empty, the trailing colon may be omitted, but if USER is
    empty, a leading colon must  be supplied.

    If you specify "--chown=foo:bar, this is exactly the same as specifying
    "--usermap=*:foo --groupmap=*:bar", only easier.

また、-o-gオプションが必要です。それらを除外すると、それぞれの属性の更新に失敗しますが、エラーは発生しません。

rsync -og --chown=cmsseren:cmsseren [src] [dest]

これは、オプションが「を使用して内部で実装されている」と述べているマンページで間接的に言及されてい--chownます。--usermap--groupmap

以下のために--usermapオプションがどんな効果を持っている、-o--owner)オプションを使用(または暗示)、および受信機は(も参照のスーパーユーザーとして実行する必要がありますする必要があります--fake-superオプション)。

ための--groupmapオプションは、任意の効果を有すること、-g--groups)オプションが使用される(または暗示)、受信機は、そのグループを設定する権限を持っている必要がありますされなければなりません。


5
なぜ-ogが必要なのですか?私には論理的ではないようですが、私のシステムにも必要です。
Yai0Phah

4
@FrankScience Agreeed、それは非論理的なようです。同じ質問がrsyncメーリングリストで尋ねられました「私はのためのドキュメントがあることを示唆している--chownことを言及してよいでしょう--owner--super)および--group必要とされています」
TachyonVortex

5

rsyncの最後のバージョン(少なくとも3.1.1)では、「リモート所有権」を指定できます。

--usermap=tom:www-data

tomの所有権をwww-data(別名PHP / Nginx)に変更します。クライアントとしてMacを使用している場合は、brewを使用して最新バージョンにアップグレードします。そして、サーバー上でアーカイブソースをダウンロードし、それを「作成」します!


弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.