Drush rsync permission woes (files directory) I'm rsyncing just the files directory (rest of the site is done through git) from my local Ubuntu setup to my centOS server. It worked at least (thankfully), but produced a ton of errors.
First it said:

rsync: failed to set times on &quot;/home/myuser/mycentossite/sites/default/files/ctools&quot;: Operation not permitted (1)

Then tmp files and js files stated play up (sometimes happens on Ubuntu setup when clearing cache also)

rsync: mkstemp &quot;/home/mycentosuser/mysite/sites/default/files/js/.js_ouzQFXPVCjfNTxl3b4ONpKTE.js.nghTEc&quot; failed: Permission denied (13)
rsync: send_files failed to open &quot;/home/myubuntuuser/websites/mysite/sites/default/files/tmp/file5GjL&quot;: Permission denied (13)

I fixed the permissions errors gradually with CHOWN and things started to work on the site. Though I'm wondering what is the correct way to go about rsyncing between local/remote in regard to permissions? And what happens if I rsync again - will it overwrite the stuff I've changed the permissions for? Or just add the new files?
Somewhat related.. My CentOS setup which uses the DSO PHP handler is also nagging me whenever I visit a page which generates a new folder of some kind. Is there way to set this up without having to go around putting CHMOD 777 on everything? (I'm the only user, so 777 in itself is not a problem for me...)
Thanks for any thoughts :)
Permissions issues are fairly complicated.

First off, the "failed to set times" message occurs because only the file owner can perform this operation.  The solution to this problem, then, is to insure that the 'remote-user' element of your Drush site alias is the same as the owner of the files on the target machine.  When pulling files to the local machine with drush rsync, it works best if you run Drush as the same user that the files are owned as.

What specific sets of permissions you choose after that is largely up to you, as there are a number of options that will work fine.  What I do is make all web server code files owned by a 'www-admin' user on the live site, and owned by my local user on my dev site.  On both live and dev, the files group is the webserver group, usually www-data, with directories that the webserver can write to being group-writable (and all others are set to not be group-writable, of course).  Any file created by the webserver will by necessity be owned by the webserver, of course.

This works well for most situations; however, it does mean that if you rsync %files from dev to live, you won't be able to overwrite anything that was uploaded by the webserver.  You might consider this a useful feature, though, as it prevents accidental overwrites.