Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My umask is 0002.

So when I rsync -r me@remote:new ., why aren't the results group-writable?

drwxrwsr-x 10 root       developers 4096 Aug 22 12:55 .
drwxrwsr-x 12 root       developers 4096 Jul 14 19:05 ..
drwxrwsr-x  3 root       developers 4096 May 16 15:04 old
drwxr-sr-x  4 aaronadams developers 4096 Jun 26 15:17 new
share|improve this question
add comment

3 Answers

I think the setgid is confusing things. Look at the -p option in the rsync man page.

share|improve this answer
    
It wasn't setgid, but the complete description for -p does indeed clear things up. –  Aaron Adams Aug 23 '13 at 16:05
1  
Great glad to get you pointed in the right direction, upvoted your anwser –  TheFiddlerWins Aug 23 '13 at 16:33
add comment

What is the permissions set in the original?

The umask is a filter not a setting. On other words it limits the permission bits that can be set for files (and directories). It doesn't force or require that any permissions get set, only that certain bits cannot be set.

If you need group write to be set, you may need to run chmod after the rsync.

share|improve this answer
    
Since there's a -p option described as "preserve permissions", I assumed omitting -p would not preserve source permissions. It turns out this is wrong! Thanks for leading me in the right direction. –  Aaron Adams Aug 23 '13 at 17:44
add comment
up vote 2 down vote accepted

I incorrectly assumed that an rsync push/pull without the -p flag would work similar to a git push/pull, and that new files would have full permissions minus the umask.

However, even without the -p flag, rsync still preserves the source file's permissions. The -p flag merely instructs rsync to (attempt to) ignore the receiver's umask.

As per man rsync:

New files get their "normal" permission bits set to the source file's permissions masked with the receiving end's umask setting, and their special permission bits disabled except in the case where a new directory inherits a setgid bit from its parent directory.

Better yet, there's a simple suggestion for how to create a flag that ignores source permissions:

To give new files the destination-default permissions (while leaving existing files unchanged), make sure that the --perms option is off and use --chmod=ugo=rwX (which ensures that all non-masked bits get enabled). If you'd care to make this latter behavior easier to type, you could define a popt alias for it, such as putting this line in the file ~/.popt (this defines the -s option, and includes --no-g to use the default group of the destination dir):

rsync alias -s --no-p --no-g --chmod=ugo=rwX

You could then use this new option in a command such as this one:

rsync -asv src/ dest/

(Caveat: make sure that -a does not follow -s, or it will re-enable the --no-* options.)

I guess I'll be doing this!

share|improve this answer
add comment

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.