I am building a script to copy files from a remote server. The problem is, the remote servers file permissions are pretty whack and I don't want to copy these over.
The line in my script right now is
/usr/bin/rsync -rtzul --progress -e ssh "$DEFAULT_SSH:$REMOTE_DIRECTORY" "$LOCAL_DIRECTORY"
I have seen elsewhere that you can use the --chmod
option to specify the permissions but I just don't understand the syntax for this argument! Perhaps I am being stupid?
I want to by default chmod files to 644
and directories to 755
. I hope you can help me.
Many thanks!
OK, I have worked out how to do it! I had been digging for some time before asking this question and continued digging. The arguments I were looking for are -
--chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r
To explain, this basically means:
Du = Directory Owner (
Read, write, execute
)Dg = Directory Group (
Read, execute
)Do = Directory Users (all) (
Read, execute
)Fu = File Owner (
Read, write
)Fg = File Group (
Read
)Fo = File Users (all) (
Read
)So in my case I have given directories
755
permissions and files644
permissions.I found out how to do this from - http://www.linux.com/learn/tutorials/309527-understanding-linux-file-permissions