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.

Share:
14,002

Related videos on Youtube

Granze
Author by

Granze

Rock climber, wannabe Skater, Software engineer, Milano JS founder. In love with #javascript #polymer #reactjs #linux

Updated on June 09, 2022

Comments

  • Granze
    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
      elundmark almost 12 years
      Have you solved this problem? If so, please share, as I'm having the exact same issue...
    • Granze
      Granze almost 12 years
      Unfortunately I was not able to solve the problem.
    • Boris Dalstein
      Boris Dalstein over 5 years
      Note that you don't need the -p option: it is implied by -a which is an alias for -rlptgoD (source).
  • Bruce Kirkpatrick
    Bruce Kirkpatrick over 10 years
    This 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
    shgnInc over 10 years
    Thank you, Clear and helpful.
  • geekQ
    geekQ almost 4 years
    If you already have the desired permissions in numerical form, you can use a shorter --chmod=D0770,F0660
  • Flimm
    Flimm almost 4 years
    I 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
    jeremysawesome about 3 years
    To 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