Preserving destination group and owner

Alberto Cabello Sánchez alberto at unex.es
Thu Jun 4 09:49:44 UTC 2020


Hi,

I'm trying to get an rsync updating some files without changing their owner,
groups or permissions. I've read man pages etc. stating I need to use the
"--no-o", "--no-g", "--no-p" flags, something like

rsync -r --no-p --no-o --no-g source destination

While the permissions are keeped, there is something not working as
expected or I'm missing something about owner and group, at least when
I run rsync as root/sudo. Just to get a quick (non-)working example,
when I run this commands (delete files, create two different files,
rsync them) as a non-root user:

sudo rm /tmp/sample1 /tmp/sample2 2> /dev/null
/bin/date > /tmp/sample1
sleep 3
/bin/date > /tmp/sample2
echo "Before rsync:"
ls -l /tmp/sample1 /tmp/sample2
sudo rsync -r --no-o --no-g /tmp/sample1  /tmp/sample2
echo "After rsync:"
ls -l /tmp/sample1 /tmp/sample2

I get this:

Before rsync:
-rw-r--r-- 1 user01 group01 30 jun  4 11:39 /tmp/sample1
-rw-r--r-- 1 user01 group01 30 jun  4 11:39 /tmp/sample2
After rsync:
-rw-r--r-- 1 user01 group01 30 jun  4 11:39 /tmp/sample1
-rw-r--r-- 1 root   root    30 jun  4 11:39 /tmp/sample2

I started with "rsync -azvhc" but I've stripped it to a minimum. Also
I run "rsync" as root user ("su -", not "sudo") with the same results.

Any help would be appreciated.

Regards,

-- 
Alberto Cabello Sánchez
Servicio de Informática
Universidad de Extremadura



More information about the rsync mailing list