Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have an rsync setup that transfers files from my local development machine to my production web server. On the production server, the storage directory needs to be 775.

When the rsync completes, it gets changed to 755

share|improve this question

2 Answers 2

up vote 1 down vote accepted

From man rsync:

-p, --perms                 preserve permissions

Assuming that you want to preserve all metadata and not just permissions, you probably want to use -a with -HAX, which implies -p.

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
share|improve this answer

I add this answer since the accepted one doesn't do the required stuff for me (using -p does not prevent rsync to change perms on destination path)!

Indeed, the appropriate option here (for NOT changing perms of existing stuff) is --no-perms

rsync --no-perms src/ /dest

Hereafter extract from the rsync man:

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).

share|improve this answer
    
--no-perms is the default already, it shouldn't be necessary in this example. –  sourcejedi Jul 24 at 19:30
    
@sourcejedi as far as I understand it rsync try to reproduce by default the same permission from the source to the dest, so the option --no-perms is not the default! –  prodev_paris Jul 29 at 11:10
    
If permission bits are turned off in the source file, rsync will apply the same to the destination file, --no-perms is the default and adding it does not change behavior. The man page does suggest adding --chmod=ugo=rwX if you want to re-enable the permission bits in the destination file, so I think that's the option you need. Ownership (including group) is not copied by default, it's just the permission bits. –  sourcejedi Jul 29 at 13:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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