rsync permissions question -- destination perms not properly applying [closed]
--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.
You have to use --chmod
with -p
options, like this:
$ rsync -avz --chmod=o-rwx -p tata/ tata2/
And here is a full test:
Create some file in a folder
$ mkdir tata$ mkdir tata2$ cd tata$ touch tyoto$ touch tiuti
The default perms are: u=rw, g=r, o=r
$ ls -l total 0-rw-r--r-- 1 romain users 0 fév 16 11:48 tiuti-rw-r--r-- 1 romain users 0 fév 16 11:48 tyoto
Try an rsync without params
$ cd ..$ rsync -avz tata/ tata2/
The destination perms are the same than the source files
$ ls -l tata2total 0-rw-r--r-- 1 romain users 0 fév 16 11:48 tiuti-rw-r--r-- 1 romain users 0 fév 16 11:48 tyoto
Specify the rsync options --chmod=o-rwx -p
$ rsync -avz --chmod=o-rwx -p tata/ tata2/$ ls -l tata2total 0-rw-r----- 1 romain users 0 fév 16 11:48 tiuti-rw-r----- 1 romain users 0 fév 16 11:48 tyoto
And now your perms are ok.
I think you need to add --perms
(aka -p
). Quoting from the manpage:
When this option is off, permissions are set as follows:
...
New files get their "normal" permission bits set to the source file's permissions masked with the receiving directory's default permissions (either the receiving process's umask, or the permissions specified via the destination directory's default ACL), and their special permission bits disabled except in the case where a new directory inherits a setgid bit from its parent directory.
I suspect your destination system has a typical umask like 022 which is preventing the group write bit from being set by rsync. Unfortunately --chmod
doesn't mention how the umask does or does not apply.