I have the following case:
Server A has a user marco with userid 10001Server B has a user marco with userid 10004
I'm copying a file test.txt, owned by marco, from server A to server B, with rsync -avz running on server B as root.
Will rsync preserve the owner if the userid is different?
1 Answer
Yes and no.
If you're a normal user on server B, rsync cannot do anything about file ownership – all files created by you will be owned by you, end of story. Thus, if you're connecting to server B as "marco", the files will be owned by "marco" (10004).
If you have root privileges on server B and don't use any special options, then rsync will preserve the username – files will be owned by user "marco", no matter what UID it has.
If you have root and use
--numeric-uids, rsync will preserve the UID – files will be owned by UID 10001, no matter which user it belongs to.