6

I have two directories with same PHP application in every of them. I want to execute rsync -rvz from one, source directory to another, destination, so rsync will copy changed files only. Problem is that files in the source directory has 755 permissions, by mistake. Permissions in destination are fine.

How can I tell to rsync ignore permission checkings and check by size only? Thanks.

4 Answers 4

7

As long as you don't supply the -p flag permissions shouldn't be changed. If you're still not getting the permissions you expect make sure perms is off and use --chmod=ugo=rwX

For reference: http://linux.die.net/man/1/rsync

 -r, --recursive             recurse into directories
 -v, --verbose               increase verbosity
 -z, --compress              compress file data during the transfer
 -n, --dry-run               perform a trial run with no changes made

 -p, --perms                 preserve permissions
 -E, --executability         preserve executability
     --chmod=CHMOD           affect file and/or directory permissions

-p, --perms This option causes the receiving rsync to set the destination permissions to be the same as the source permissions. (See also the --chmod option for a way to modify what rsync considers to be the source permissions.)

The man page goes on to say:

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

Side-note: If possible it might make more sense for your developer to be pushing their changes back into the repo, and have all servers use a code repo, rather then use rsync to ship files form one server to the other.

1
  • 1
    The first sentence in bold is not quite right (or at least it is confusing) because the typically recommended flag -a implies -p, as stated by the other answers
    – cxrodgers
    Aug 10, 2023 at 13:56
17

If you supply the -a flag -p is automatically included. If you specify --no-p all of the other options from -a remain intact.

6

Most options can be turned off by simply adding the --no- prefix to those options.

Example:

rsync -avz --no-perms --no-owner --no-group /local-dir/ my-server:/remote-dir/

This will disable syncing permissions, ownership, and groups.

2
  • 1
    -a is just a set of -rlptgoD; disabling permissions, groups, ownership, plus we don't care about symlinks and devices most of the time, leaves us with just -rt
    – dimavs
    Mar 21, 2023 at 0:51
  • 1
    @dimavs You are correct. The point however is that sometimes I don't want to go finding out exactly what a flag such as -a means on my exact platform (especially when appropriate man pages for that platform is scarce [think Android, home printer, or router]). Maybe I just want sane defaults for that platform with some specific option removed. Jan 20 at 2:25
2

I may be mistaken but without the -p it shouldnt change the permissions. (also -a which is archive would preserve it, but you're not using that either obviously)

1
  • yes, I think so too. But when I execute rsync with "-n" option I see so many files. I concrete: copy of application is from one of developers. I want to sync his code with a state of repo. So I think to rsync only changed files is the best way. After this I'll add them into git. That's why i'm surprised to watch some images and skins. Okay, thanks. Apr 2, 2013 at 21:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .