Rsync Daemon Not Preserving Owners or Groups on macOS

daemonmac-osxrsync

I am setting up a new internal backup strategy where multiple hosts on my LAN will be backed up to a single host running the rsync daemon.

I am still in the early stages of this, backing up a directory tree on the same host as the rsync daemon and have run into a serious problem. Rsync is not preserving the owners or groups of the files.

The host that is running the rsync daemon is a Mac Pro running macOS 10.13.4.
It has Homebrew V1.6.6 installed.
I installed rsync V3.1.3 with Homebrew.
The rsync daemon is running as root (ls -Al shows uid to be 0).
There are no errors in the log file.

The rsyncd.conf file:

# /usr/local/etc/rsyncd.conf
[global]
    uid = 0
    log file = /Volumes/Data01/Projects/DPLHInternal/Backup/rsync.log
    max verbosity = 3

[users]
    comment = Mac user directories
    path = /Users
    read only = true
    exclude = .Trash

The rsync command (as a bash script):

#!/usr/bin/env bash
# rsync_local.sh
rsync \
  --stats \
  --human-readable \
  --archive \
  --acls \
  --executability \
  --owner \
  --group \
  --numeric-ids \
  --perms \
  --xattrs \
  rsync://localhost/users/ /Volumes/Data03/Backups/Rsync/Dave/users

In the /Users directory there is a sub-directory named Guest. This folder and its contents are owned by Guest:_guest (201:201).

After running the rsync command, the destination directory and its contents are owned by dpatterson:admin (501:80, dpatterson is my username).

I have tried with and without –numeric-ids.
I have tried running the rsync command as root. The copied folder and its contents are then owned by root.
I have tried with and without explicitly specifying –owner –group.

All to no avail.

I figure I must be missing something fairly basic.

TIA

Best Answer

Try running it directly from the command line as root with this command

rsync -avzH

That effectively does what you are trying to do with your script but it's little cleaner and also preserves hard links. If it's working directly from the command line, perhaps it'll help you debug what's occurring with your script.