3

I am having a slight problem. I use rsync (Cygwin) in Window and the files that are synced in my remote folder is not right.

rsync -r /cygdrive/c/xampp/htdocs/mysite/* me@mysite.com:/home/mysite/public_html/

Right now, I use rsync to upload the files BUT then I have go into my remote directory and manually change the file/folder permissions myself.

Does rsync have an option to CHMOD, etc.?

Thanks, Wenbert

EDIT: I'd like the files to be 644, etc.

wenbert
  • 145
  • 1
  • 7

2 Answers2

5

Cygwin does not understand NTFS ACLs and cannot replicate them. You'll always end up with goofy permissions on the remote side using rsync.

The two methods I've either used or heard recommended to get around the problem are:

  1. Periodically run a fixup script on the remote server, using cacls.exe or some variant thereof to correct the ACLs. The con of this technique is that your script needs to be kept up to date, otherwise permissions on the destination side won't match the source. This is difficult to maintain.
  2. Follow your rsync run with a robocopy.exe run, but only use robocopy to replicate the NTFS ACLs from source to destination. This requires that you be able to connect to the destination server using an SMB share or similar technique, which means you're supporting both cygwin/rsync/ssh and also an SMB share.
Larry Silverman
  • 567
  • 6
  • 13
4

If you want to force the permissions at the destination, you'll need to use the --chmod option and/or the --perms option.

  • --chmod overrides the source permissions (ie rsync pretends that the source permissions are whatever you specify instead of what they actually are)
  • --perms (or -p) forces the source permissions onto the destination server

For example:

rsync --chmod=a=r,u+w,D+x -p -r /cygdrive/c/xampp/htdocs/mysite/* \
    me@mysite.com:/home/mysite/public_html/

You didn't mention what cygwin considers the source permissions to be (ie an ls -l /cygdrive/c/xampp/htdocs/mysite/* in cygwin) or what the actual permissions wind up being on the destination side. If we knew that, it might be possible to construct something a bit simpler.

For a thorough illumination of the various options, consult the very-detailed rsync manpage.

Note that rsync does not yet support octal permissions (eg --chmod=644). According to this post, support for that will be available in rsync 3.1.0.

fission
  • 3,601
  • 2
  • 21
  • 31