Forceably set permissions when running rsync
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?
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.
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.