Can you pass a chown command during an rsync call?

CMSCSS picture CMSCSS · Oct 3, 2014 · Viewed 16k times · Source

Title says it all really.

I see that you can preserve owner:group but is it possible to change the owner:group on all files on the remote after they've been synced?

Or can you somehow pipe an extra command?

rsync -vzrP --delete ~/Sites/website-name/ [email protected]:/home/website-name/public_html/ | chown website-name:websites-group *

Sorry, my rsync/bash knowledge is pretty limited.

Answer

Chris Jester-Young picture Chris Jester-Young · Oct 3, 2014

Yes, rsync provides the --usermap and --groupmap options to allow you to customise how these are mapped at the remote end.

For your particular use case, where all files are to be mapped to the same user/group combo, you can use the --chown option, which is a shortcut for the above.