How to keep owner on destination file

Janning Vygen vygen at
Thu Oct 26 10:14:11 GMT 2006


i am using rsync since years and i think it's one of the must-use tools. 

Today i got my first problem after years of usage and the fantastic manpage 
doesn't give me any answer, neither the web does.

I am starting with two directory "foo" and "bar" with a text file "test.txt" 
in each of it. "foo" and "bar" and "test.txt" belongs to different owners. 

     -rw-r--r-- 1 janning janning 12 bar/test.txt
     -rw-r--r-- 1 postgres postgres 6 foo/test.txt

Now i want to sync the content of test.txt WITHOUT changing the ownership 
(group, permissions, timestamp etc) on destination file (bar/test.txt)

I run rsync as root to get the permission to overwrite those files:

     # rsync bar/ foo/

     -rw-r--r-- 1 janning janning 12 bar/test.txt
     -rw-r--r-- 1 root root 12 foo/test.txt

Content is synced but ownership is set to "root". Of course i know "--owner" 
to preserve the ownership. But this results in 

     -rw-r--r-- 1 janning janning 12 bar/test.txt
     -rw-r--r-- 1 janning janning 12 foo/test.txt

I need an option like "--preserve-ownership-on-destination", like "cp" it 
should only copy the file and not its attributes like owner/group/permissions

Is it possible at all with rsync? Or did i miss something? 

kind regards 

More information about the rsync mailing list