ubuntu 10.04 - rsync - setting file permissions problem

04
2013-09
  • TheVillageIdiot

    I am using rsync to synchronize folders between two Ubuntu Lucid Lynx systems.

    rsync -az --delete -e "-i /home/ruser/.ssh/id_rsa_ruser -p 200" 
              /usr/local/folder/ [email protected]:/usr/local/backup/folder/
    

    Everything is going fine except I am getting following problem:

    rsync: failed to set permissions on "/usr/local/backup/folder/README.txt": 
             Operation not permitted (1)
    

    On remote system (192.168.1.2) ruser is member of tnr group which is owner of /usr/local/backup/folder/. The folder's permissions are as follows:

    drwxrwxr-x 3 tom tnr 188416 2011-06-20 18:04 folder
    

    Please help me to resolve the error or any method to bypass changing permission setting by rsync.

    EDIT:- I had sorted this out by creating group tnr on source server and setting it as owner of source folder.

  • Answers
  • Caleb

    You cannot change the file timestamps or change permissions by being a member of a group, you have to be the file owner, or root. If you cannot be the other of that file, you might need to avoid trying to set permissions at all. You can do this with the perms option (after your other options because -a includes a bunch of stuff including the positive of this) like so:

    rsync -az --no-perms

    You can see some discussion about the underlying systems involved on this related question.


  • Related Question

    rsync file permissions on windows
  • avguchenko

    I have an rsync service that syncs files from remote machine to a machine that drops them on a network drive.

    I need the copied files to take on the native permissions of the destination folder.

    The sync process runs fine, but after it is finished, I cannot access some of the folders -- Permission Denied.

    I am logged in as domain admin; it won't allow me to modify any permissions on said folders, either. What gives?

    run command:

    rsync.exe  -v -rlt -z --delete "src_path" "dst_path"
    

  • Related Answers
  • avguchenko

    (from http://www.samba.org/ftp/rsync/rsync.html)

    In summary: to give destination files (both old and new) the source permissions, use --perms.

    To give new files the destination-default permissions (while leaving existing files unchanged), make sure that the --perms option is off and use --chmod=ugo=rwX (which ensures that all non-masked bits get enabled).

    If you'd care to make this latter behavior easier to type, you could define a popt alias for it, such as putting this line in the file ~/.popt (the following defines the -Z option, and includes --no-g to use the default group of the destination dir):

        rsync alias -Z --no-p --no-g --chmod=ugo=rwX
    
  • miking

    Cygwin's "posix" security has caused me lots of problems with Windows NTFS file permissions - even using --no-perms with rsync.

    I found that newly-created files/folders don't properly inherit default permissions, but every file/folder ends up with lots of <not inherited> entries in the Windows file/folder Advnanced security tab. (And this problem is not just rsync-related).

    I found this related post and this link both very helpful in how to resolve these problems using the noacl option in cygwin's /etc/fstab file. The downside of this solution is that cygwin loses the ability to set file/folder permissions, but in many cases this is not important.

    (Googling this topic you'll probably find references to setting the CYGWIN=NONTSEC environment variable, but this is for cygwin v1.5 and doesn't work in cygwin v1.7 onwards.)

  • Wernight

    On Windows with DeltaCopy I could make it work with:

    rsync --perms --chmod=a=rw,Da+x ...
    

    It worked even with --recursive