I'm having problems synchronising file permissions with rsync. I'm trying to sync my /home/bin folder with the /home/bin folder on a remote machine. The problem is that when I write a new script and make it executable with 'chmod +x' then after performing rsync, the file reverts back to being unexecutable.

If I use --perms, when I update the file permissions on the remote machine and then use rsync on the host machine, the file permissions don't get updated on the host machine and on the remote machine they get reverted back.

Is there a way to properly sync the file permissions?

UPDATE: I forgot to post the script I use:


rsync -e ssh -avz --recursive --progress --update --perms /home/bin username@example.com:/home                                                                              
rsync -e ssh -avz --recursive --progress --update --perms username@example.com:/home/bin /home

I think your basic problem here is that rsync is not a good tool for two-way synchronization. I would recommend some solution conceptually different, otherwise you will keep clobbering yourself.

  • You could look into using Unison. It functions similar to rsync but is designed for two say synchronization.
  • Better yet, look into using a source control system like git. This is particularly useful for things like config files and your personal scripts. Each machine you use them on will have a separate checkout, and the versioning takes care of making sure that you always have the latest changes by time including merging multiple different changes rather than just having the data clobbered from any one source.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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