How to keep owner on destination file

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


Hi,

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

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/

Result:
     -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 
Janning


More information about the rsync mailing list