rsync ownership oddity - bug or feature?

Karl Auer kauer at biplane.com.au
Wed Apr 20 21:51:48 UTC 2022


I ue rsync a LOT, and yesterday something new to me popped up.

Let's say I have two directories, /source and /destination. /source is
owned by fred:fred, /destination is owned by mary:mary.

I want to copy the contents of the /source directory into the
/destination directory. Note that I am not coping the source directory
itself, just the contents. And I want all the copied files to have the
same ownership and permissions as their originals.

So I run this commend as root:

   rsync -a /source/ /destination

It all works exactly as expected except that afterwards, /destination
is owned by fred:fred.

Why?!? And is there anything I can do in the rsync command to stop this
behaviour?

Regards, K.

PS: This behaviour came to light because I was using rsync to update a
git repository. On April 8 2022, Ubuntu released a security update that
basically causes git to complain and fail if the user running git is
not the owner of the repository. Rather unexpectedly, my repo was no
longer owned by root, so error messages all over the place. My
workaround was to follow the rsync command with a chown command, but
IMHO it should not have been necessary.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer








More information about the ubuntu-users mailing list