Search code examples
linuxsshpermissionsrsync

Setting group for all files and folders with rsync


I'm sending some files to my production server with rsync and would like to ensure that all users in a group can perform the deploy.

How can I ensure that the rsync script sets both:

  • The correct group (www-data)
  • The correct permissions (read,write,execute for all members of the www-data group)

So far, the command looks like this, and uploads the files, and sets the permissions that I'd like. However, I'm not sure how to set the group for every single file and folder, recursively.

rsync -rvp --chmod=u+rwx,g+rwx,o=rx public/ [email protected]:/var/www/mysite

I've read you can use the --chown option, but that keeps giving me the following error: no matches found: --usermap=*:www-data

What's going wrong? Here's the last command that I tried:

rsync -rv -og --usermap=:www-data --groupmap=:www-data --chmod=u+rwx,g+rwx,o=rx public/ slave:/var/www/mysite.com


Solution

  • This was the command that I ended up using. For some reason, my shell was expanding the --chmod command and failing (due to the *).

    rsync -rv -og --usermap="\*:www-data" --groupmap="\*:www-data" --chmod=u+rwx,g+rwx,o=rx public/ [email protected]:/var/www/mysite