LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rsync Not Retaining Permissions (https://www.linuxquestions.org/questions/linux-software-2/rsync-not-retaining-permissions-859283/)

carlosinfl 01-28-2011 01:21 PM

Rsync Not Retaining Permissions
 
I've got an older RHEL 5.5 server that we're using for our company email server. We're going to retire this server and I've created a new Debian Linux server as it's replacement. Now I'm trying to rsync all the users /home/ directories to the new server however when I tested this, I noticed a problem. In the old source server where I'm running the actual rsync command from, everyone's home directory is owned by their unique UID and a generic GID (100 = users). So when I execute this command on the old RHEL 5.5 server:

Code:

rsync -e ssh -avz /home/* root@192.168.0.101:/home
Why are all the users home directories being owned by root:root on the target server? It's not owned by root:root on RHEL 5.5 and the only thing I can think of is my rsync command is wrong. According to the man page, I can see that using the -a switch should preserve all file ownership and much more. It's not doing this on the target Debian server. If it tries to copy over /home/bob and it's owned by bob:users, if Debian didn't know or have a UID for Bob, wouldn't it just assign a UID from RHEL 5.5 to the Debian server? So like /hone/bob would be owned by 1009:users?

Anyone know what I'm doing wrong?

wpeckham 01-28-2011 01:59 PM

rsync
 
Not sure I can help, as I have not been able to replicate this problem.
I may be able to make something clear, the '-a' option preserves ownership by UID, not by name. The files SHOULD land with the same UID and GID NUMBERS as on the old server. Only if you have gone through the steps to ensure that the account names and account and group numbers MATCH on the two servers will you get the results you expect by name.

Rsync with -a should NEVER modify the ownership from what it was on the source, but there are some complicating factors. It does NOT allow the receiving OS to just "guess" or be creative with the new values. If the rsync process lacks the permission to change ownership or permissions after the copy you CAN see some very odd results. Did you log the output and check for warnings and error messages?

carlosinfl 01-28-2011 02:01 PM

That's exactly what I would expect from the command I posted above. If I rsync the folders / files over to the new server, they should all have random UID's for the owner of the /home/ folders but that's not what I'm seeing. I show they all our owned by root:root on the target server but on the source server, the users home folders are all owned by their unique UID and have a permission mask of 700. Don't understand why this is happening.

wpeckham 01-31-2011 10:39 AM

Rsync
 
I find that I can replicate the behavior, but not using that command-line.

If you do NOT specify to preserve ownership and permissions ( -p -g and -o , all among those implied by -a ) then it lands with the ownership and permissions set by the receiving user.

If the receiving end is run by root, then the files and folders belong to root.

The standard compile options on recent version specifically make ssh the default. I have not investigated the RHEL 5.5 version itself, but would be GREATLY surprised if the RH guys had neglected to make security the default!

1. Try leaving off that '-e ssh' option.

2. check that you have ONLY ONE rsync executable on each machine, so that only the recent version can be called. (I would not delete any unexpected additional instances of rsync, but you might compress any that you find for the duration of a test.) If you have and must preserve multiple versions, call the correct oe using a full path. Make sure that the correct rsync is the first one found in the path of the user on the remote end.

Please let me know what you find.


All times are GMT -5. The time now is 06:06 AM.