rsync deploy and file/directories permissions
14,002
Try it like this :
--chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r
It worked for me.
Related videos on Youtube
Author by
Granze
Rock climber, wannabe Skater, Software engineer, Milano JS founder. In love with #javascript #polymer #reactjs #linux
Updated on June 09, 2022Comments
-
Granze almost 2 years
I'm trying to use rsync to deploy my website that resides on a shared web host.
Phpsuexec is running on it and that caused me problems with permissions on files and directories I've transfered via rsync. Actually files should be set to 644 and directories to 755, otherwise I get a 500 error.
After several attempts, I came with this rsync command:
rsync -avz -e ssh --chmod=Du=rwx,go=rx,Fu=rw,og=r -p --exclude-from=/var/www/mylocalfolder/.rsyncignore /var/www/mylocalfolder/ [email protected]:~/
Unfortunately this command doesn't works as expected because all the sent directories have been set to 744. On the other hand, files permission have been correctly set on 644.
I can't understand what is wrong.
P.S. I use Linux on my local machine.
-
elundmark almost 12 yearsHave you solved this problem? If so, please share, as I'm having the exact same issue...
-
Granze almost 12 yearsUnfortunately I was not able to solve the problem.
-
Boris Dalstein over 5 yearsNote that you don't need the
-p
option: it is implied by-a
which is an alias for-rlptgoD
(source).
-
-
Bruce Kirkpatrick over 10 yearsThis works for me. I wanted to do 770 for directories and 660 for files, which works with this flag: --chmod=Du=rwx,Dg=rwx,Do=,Fu=rw,Fg=rw,Fo=
-
shgnInc over 10 yearsThank you, Clear and helpful.
-
geekQ almost 4 yearsIf you already have the desired permissions in numerical form, you can use a shorter
--chmod=D0770,F0660
-
Flimm almost 4 yearsI think you also need to check that
--perms
is passed, and that the current user has permission to change the permissions of that file. -
jeremysawesome about 3 yearsTo set the permissions on a file or folder to none for a specific group you can simply assign nothing after the
=
symbol. For example, to set the directory permissions to 750 and the file permissions to 640 you can use the following:rsync --chmod=Du=rwx,Dg=rx,D=,Fu=rw,Fg=r,Fo= --recursive ~/my/old/location ~/my/new/location
if you do not specifically set permissions, they will be set to whatever the source permissions are