0

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

  • I don't think it's something basic, I think it's something specific with your rsync's compilation or filesystem dependent. It should work out of the box. In Linux it does. You can try to add verbose and debug flags to rsync. Make sure it tries to chmod/chown the files, then strace the process to see whether you see proper system calls. – Michal Sokolowski Jun 7 '18 at 16:53
0

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.

  • He's already using --archive which is long form for -a. The key thing is that when running as a normal user, rsync can't write files as another user. So the hint about running as root is what is the real answer. Also the module defintion on the server needs uid = 0 to backup all files, including those unreadable for user nobody which is the default. Finally for best results include the -H option to preserve hard links. You may want to edit your answer... – wurtel Jun 7 '18 at 14:12
  • You are correct. I'm so used to doing everything directly from the command line that I didn't notice the long --archive. I will edit. – Nasir Riley Jun 7 '18 at 14:54
  • The key turns out to be running both the daemon and the command line as root. – David Patterson Jun 8 '18 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.