Lsyncd 2.2.2 の所有権と権限の問題

Lsyncd 2.2.2 の所有権と権限の問題

ファイルがリモート サーバーにコピーされるのですが、ターゲット サーバー上の複製されたファイルの所有者/グループが常に「1002」になるという問題が発生しています。ソースの権限は尊重され、ターゲットに正しく複製されます。複製されたファイルの所有者 (およびグループ) を保持する方法がわかりません。

Lsyncd バージョン: 2.2.2

私の設定は以下の通りです:

settings {
    logfile = "/var/log/lsyncd/lsyncd.log",
    statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
    default.rsyncssh,
    source="/home",
    host="1*52.*.15",
    targetdir="/home/",
    delete = "running", -- prevents deletion of files on startup (ie when a server comes back online, don't delete files that are new on the backup)
    delay = 5, -- run every 5 seconds instead of default 20
    exclude = {
        "/home/backup",
    },
    rsync = {
        archive = true, -- use the archive flag in rsync
        perms = true, -- Keep the permissions
        owner = true, -- Keep the owner
        compress = true,
        acls = true,
            xattrs = true,
        _extra = {"-a"}, -- Sometimes permissions and owners isn't copied correctly so the _extra can be used for any flag in rsync
    }
}

lsyncd ログ エラー:

Dec 15 21:42:47 server1.*.group lsyncd[21033]: sending incremental file list
Dec 15 21:42:47 server1.*.group lsyncd[21033]: rsync: failed to set times on "/home/admin/conf": Operation not permitted (1)
Dec 15 21:42:47 server1.*.group lsyncd[21033]: admin/conf/
Dec 15 21:42:47 server1.*.group lsyncd[21033]: sent 5,387 bytes  received 160 bytes  3,698.00 bytes/sec
Dec 15 21:42:47 server1.*.group lsyncd[21033]: total size is 2,849,404,839  speedup is 513,683.94
Dec 15 21:42:47 server1.*.group lsyncd[21033]: rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

答え1

問題は、ローカル システム上のファイルの uid/gid がターゲット システムの uid/gid と一致していないことにあると思います。

ローカル システム上のユーザー/グループ ID を確認し、ターゲット システムに同じユーザー/グループを作成します。

# On source system
$ ls -l /home/admin/conf
-rw-r--r--. 1 user1 user1 1.0K Jul 13  2018 /home/admin/conf

$ id user1
uid=1002(user1) gid=1002(user1) groups=1002(user1)

# On target system
$ useradd -u 1002 -g 1002 user1

答え2

RSYNC が所有権を保持してファイルを送信する場合、ユーザー名/グループ名ではなく、所有者の UID と GID を送信します。

したがって、1002 の経験は、その UID がターゲット システムで使用されていないことを意味します。

この問題は、次の 2 つの方法のいずれかで解決できます。

  • 古いユーザーを削除し、useradd の UID 設定を使用して再作成します。-- chown や chmod を実行する必要がないため、これがおそらく最もクリーンな方法です。
  • usermod を使用して UID と GID を更新します。-- これを行うと、ホーム ディレクトリ内のファイルを chown する必要があり、そのユーザーが所有する他のファイルに予期しない副作用が発生する可能性があります。

リスト項目

関連情報