Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm migrating files between servers and have to map UIDs (add 500) and GIDs. As I'd like to have it done in one single pass, is there a way to execute a command for each file rsync copies?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

rsync does what you want if you give -a. Actually, you only need -o and -g, but since you're trying to preserve this much, you probably want the rest of what -a provides.

Obviously you need root permissions on the remote side for this to work. This means you need to log in as root on the remote system if rsyncing over SSH. If you're running rsync as a daemon on the remote system instead, it needs to run as root.

share|improve this answer
    
rsync doesn't do the right thing for me (I have same usernames, only uid differ). I guess rsync can't map them as users are now stored in LDAP... –  CharlesB Mar 29 '12 at 14:04
    
Sorry, I was mislead by the docs and the fact that I always use -a in my rsync commands. Rewrote my answer. I think you'll find that with -a and root permission on the remote system, you get the behavior you want despite using LDAP. –  Warren Young Mar 29 '12 at 14:56
    
I'm syncing over NFS (one of the server is an atom NAS, and SSH tunnel is kill bandwidth), and good Lord after retrying with SSH it works! I suppose I have to look into RSH, as I'll have both transfer speed and UID mapping, right? –  CharlesB Mar 29 '12 at 15:10
    
If you don't need the encryption provided by SSH, I'd suggest using rsync in daemon mode on the server side. RSH is rightly deprecated as horribly insecure. –  Warren Young Mar 29 '12 at 15:20
    
Tried it too, but rsyncd doesn't map UIDs (running as root on remote). Anyway I can't seem to login with RSH so I'll stick with NFS mount and chown stuff by scripting. –  CharlesB Mar 29 '12 at 15:33
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.