Os diretórios precisam de permissão de execução para que os processos os acessem (abra).
Quando você usa --chmod=a=rw
, o diretório de destino é criado, mas imediatamente obtém suas permissões definidas como drw-rw-rw
, de modo que seu conteúdo fique inacessível (" failed to stat
") dado
$ tree
.
└── source
├── file1
├── file2
└── file3
1 directory, 3 files
então
$ rsync --include="file*" --exclude="*" -avh --chmod=a=rw source/ destination/
sending incremental file list
created directory destination
rsync: failed to modify permissions on "/home/steeldriver/destination/.": Permission denied (13)
rsync: recv_generator: failed to stat "/home/steeldriver/destination/file1": Permission denied (13)
rsync: recv_generator: failed to stat "/home/steeldriver/destination/file2": Permission denied (13)
rsync: recv_generator: failed to stat "/home/steeldriver/destination/file3": Permission denied (13)
./
sent 107 bytes received 502 bytes 1.22K bytes/sec
total size is 0 speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
falha porque
$ ls -dl destination/
drw-rw-rw- 2 steeldriver steeldriver 4096 Mar 23 18:24 destination/
para que
$ ls -al destination/
ls: cannot access 'destination/.': Permission denied
ls: cannot access 'destination/..': Permission denied
total 0
d????????? ? ? ? ? ? .
d????????? ? ? ? ? ? ..
A solução é usar --chmod=a=rwX
(ou, equivalentemente, --chmod=ugo=rwX
)
$ rsync --include="file*" --exclude="*" -avh --chmod=ugo=rwX source/ destination/
sending incremental file list
created directory destination
./
file1
file2
file3
sent 224 bytes received 110 bytes 668.00 bytes/sec
total size is 0 speedup is 0.00
em que o modo simbólico X
significa
execute/search only if the file is a directory or
already has execute permission for some use
Veja man chmod