rsync permissions question -- destination perms not properly applying

Philip Walton picture Philip Walton · Nov 6, 2010 · Viewed 45.8k times · Source

This is what I'm trying to do:

rsync -rvl --chmod=ug=rwX,o=rX test /var/www

and after I do it, here are the results I get:

drwxr-xr-x

(Actually it's drwxr-sr-x, but that's probably not important ... is it?)

This, obviously is not what I want. I want the group to have write permissions, but for some reason, the rsync command isn't setting them.

Anyone have any ideas why not? Is there a mistake in my syntax? If it's helpful I'm transferring from OSX to Linux (Debian).

Update: Also, if it's helpful, when I enter umask, I get 0002. So that's not the problem.

Answer

SimonJ picture SimonJ · Nov 6, 2010

--chmod overrides the sending side permissions, but if you don't specify -p or --perms as well then the destination defaults are used regardless (i.e. --chmod is ignored).

From man 1 rsync:

--chmod

This option tells rsync to apply one or more comma-separated "chmod" strings to the permission of the files in the transfer. The resulting value is treated as though it was the permissions that the sending side supplied for the file, which means that this option can seem to have no effect on existing files if --perms is not enabled.