How to manage root<-->root rsync keeping permissions?

Paul Slootman paul+rsync at
Tue Aug 3 11:10:33 UTC 2021

On Tue 03 Aug 2021, Chris Green via rsync wrote:

> Is there a way to copy (for example) the /etc hierarchy from one
> system to another preserving root ownership of files and without
> revealing root passwords all over the place?

Best way is to run an rsync daemon on the source system, and be sure to
use "uid = 0" so that the daemon reads the source as root.

> So, it's easy for the sending end to be run as root as it's going to be
> run by a script in /etc/cron.daily, so it can access all the files in
> /etc even if only readable by root.

Hmm I prefer to use "pull" mechanisms as that's more secure (harder to
screw up the destination).

So create a /etc/rsyncd.conf file with the appropriate config, something

  path = /etc
  read only = yes
  hosts allow = another-system
  uid = 0

If using systemd then enable and start the daemon:

systemctl enable rsync.service
systemctl start rsync.service

Then on another-system as root run rsync:

rsync -a one-system::etc/ /backups/etc/

I usually also use -H for hard links, but /etc usually won't have those.

You can also use an rsync password to make this a bit more secure so
that not everyone on another-system can read all of /etc from
one-system. Details in the manpage.


More information about the rsync mailing list