Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Currently I am backing up gigabytes and gigabytes of data from a live server to a backup server using an rsync/ssh combination script, allowing for automated operation every night with a cron job.

The problem I am having is with permissions.

Running rsync with -a mode copies over the user:group and filemode, which are currently 54122:games and -rwx--S---.

In order to be able to execute the files on the backup server (don't ask me why the employer requires this), I've had to run a time- and cpu-costly (because of the sheer amount of data transferred) chown() and chmod() setting every file/folder to www-data:www-data and permissions of 755.

Is there anyway I can setup rsync to forcibly set each file/folder to www-data:www-data and 755 or am I looking at this problem from the wrong angle?

I guess I could run -rltD instead of -a (which is equivalent to -rlptgoD) but then what happens to new files? What permissions and owner:group settings do they receive?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

Amongst many other options rsync can change permission by running it with the option:

rsync [options] --chmod=CHMOD source destination

where you can also combine option --archive with the option --no-owner or --no-perms to exclude preservation of owner resp. permissions. For further options on very subtle settings for CHMOD see the manpage for rsync.

share|improve this answer

If the permissions are already setup that way on the machine you are copying from you could try -p. It saves the permissions. Also you may want to try grsync. It's a gui for rsync that makes some of the options more apparent. Also -o preserves the owner.

Hope that helps. Good luck.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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