0

So I have a web-server that i rsync to from my personal computer, I'm having trouble with file permissions.

I have tried both of these commands, and none of them give me what I want.

rsync -a --no-o --no-g --exclude='*.json' --exclude='venv/*' --exclude='*.sh' /var/www/mysite.com/ admin-user@mysite.com:/var/www/mysite.com

rsync -a --exclude='*.json' --exclude='venv/*' --exclude='*.sh' /var/www/mysite.com/ admin-user@mysite.com:/var/www/mysite.com

Here is an explanation of what I want, and what actually happens, I get the same effect with both of the commands mentioned earlier. This is how it should be, the index is readable by www-data which is the user nginx runs under, and writeable by the admin user.

-rw-r-----  1 admin-user www-data 127 M D mm:ss index.html

This is what actually happens after running rsync:

-rw-r-----  1 admin-user admin-user 128 M D mm:ss index.html

This obviously results in a 404 when visiting the website, currently I have to run a script that corrects permissions after running rsync.

So what I want is for the GID in the files on the server to not change after I run rsync, a solution where I manually specify a GID will not work either because there are other files used by other programs which need to be set to other groups. Basically rsync should modify the data in the files but not touch anything else.

This shouldn't require super-user privileges either, as the file is writeable by the user I am logging in as.

OS: Ubuntu 16.04 Server and Desktop
rsync --version (home computer): 3.1.2  protocol version 31
rsync --version (server): 3.1.1  protocol version 31
  • try just running sudo <rsync> command – the_velour_fog Oct 10 '17 at 9:33
  • Is the admin-user member of the www-data group on the server mysite.com ? – Thomas Oct 10 '17 at 10:05
  • @Thomas Awesome, that worked, I hadn't set up group permissions for the admin user properly. Thanks, I'll add this as an answer to the question. – asdfghikku Oct 10 '17 at 13:31
1

In order for rsync to create the updated files with the same group they were originally assigned to the admin user had to be a part of that group.

The solution was to run

usermod -aG www-data admin-user

on the web server.

I just tried it and it seems to work perfectly. I used the following options for rsync:

rsync -a --no-o --exclude='*.json' --exclude='venv/*' --exclude='*.sh' /var/www/site/ admin-user@remote:/var/www/site

This was originally suggested by @Thomas in the comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.