73

When I use the -a option as is asked and answered in Preserve the permissions with rsync, I got a lot of "rsync: failed to set permissions on" errors.

rsync: failed to set permissions on "/ata/text/RCS/jvlc,v": Operation not permitted (1) rsync: failed to set permissions on "/ata/text/RCS/jvm,v": Operation not permitted (1) rsync: failed to set permissions on ... 

Why is this? The files are normal files with permission of 0664.

1
  • Can you give us ls -al output for some of the affected files? Commented Apr 28, 2011 at 17:32

8 Answers 8

61

This error happens, because operation for changing the permissions is not permitted. So either check if your user executing the commands have the correct permissions (e.g. he's not the owner), or your file system doesn't support it.

You can ignore the warnings by specifying the additional arguments to rsync to --no-perms and -O (--omit-dir-times) to avoid trying to set permissions and modification times on files/directories. This should solve the errors. Alternatively avoid using -a.

2
  • 6
    --no-perms does NOT get rid of the error, why??? Commented Mar 19, 2020 at 4:35
  • 1
    file system doesn't support it this was my gotcha Commented Apr 4, 2021 at 7:21
42

Most likely, rsync on the destination end is not running as a user with permission to chmod those files (which would have to be either the file's owner or root).

3
  • It just happened that the files are owned by _www. Changing the owner solved this issue. Thanks for the help. Commented Apr 28, 2011 at 20:56
  • 6
    It should be noted that you'll get this error even if rsync's user is in the same group a the files. To fix this error, the files must belong to the same user as rsync, not just the group. Commented Dec 21, 2015 at 21:16
  • In my case, it was a wrong default owner on the files in question. Even though the permissions (acl) were correct for routine r/w operations, updating times was not possible for some of the files. chown -R user:group $dir fixed it. Commented Nov 18 at 17:13
23

Background

Typically with rsync you'll see warnings if either:

  • the rsync server at the other end does not possess permissions to execute an action associated with the following:
  • owner
  • group
  • permissions
  • access times
  • or the filesystem on the remote side does not support the same types of metadata as the sender (permissions, ownership, etc.)

These issues will manifest themselves through the rsync client that's attempting to communicate with the rsync server showing up as as messages like this when attempting to copy files/directories over to a receiver:

owner

rsync: chown "/mnt/music/The Fleetwood Mac/Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3" failed: Operation not permitted (1)

group

rsync: chgrp "/mnt/music/The Fleetwood Mac Discography by Sketch/Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3" failed: Operation not permitted (1)

permissions

rsync: failed to set permissions on "/mnt/music/The Fleetwood Mac Discography by Sketch/Trilogy - 2006/Trilogy - 2006 - CD 3": Operation not permitted (1)

In cases where the receiving side cannot perform these operations you can instruct rsync to merely skip attempting to do them, realizing that the destination will not be strictly identical with the sender's metadata around the files. This will still create identical copies of the binary portions of the files and directories.

To tell rsync not to worry about the metadata you can use the --no-OPTION to disable any of these implied options.

rsync man page

--no-OPTION You may turn off one or more implied options by prefixing the option name with “no-”. Not all options may be prefixed with a “no-”: only options that are implied by other options (e.g. --no-D, --no-perms) or have different defaults in various circumstances (e.g. --no-whole-file, --no-blocking-io, --no-dirs). You may specify either the short or the long option name after the “no-” prefix (e.g. --no-R is the same as --no-relative). For example: if you want to use -a (--archive) but don’t want -o (--owner), instead of converting -a into -rlptgD, you could specify -a --no-o (or -a --no-owner). The order of the options is important: if you specify --no-r -a, the -r option would end up being turned on, the opposite of -a --no-r. Note also that the side-effects of the --files-from option are NOT positional, as it affects the default state of several options and slightly changes the meaning of -a (see the --files-from option for more details). 

So in our case we'll want to use something like this to disable things:

$ rsync -avz --no-o --no-g --no-perms <src> <dst> 

Example

$ rsync -avz --delete --no-o --no-g --no-perms The\ Fleetwood\ Mac/ /mnt/music/The\ Fleetwood\ Mac/. sending incremental file list Trilogy - 2006/ Trilogy - 2006/Trilogy - 2006 - CD 3/ Trilogy - 2006/Trilogy - 2006 - CD 3/301_fleetwood_mac_-_love_in_store.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/302_fleetwood_mac_-_cant_go_back.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/303_fleetwood_mac_-_thats_alright.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/304_fleetwood_mac_-_book_of_love.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/305_fleetwood_mac_-_gypsy.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/306_fleetwood_mac_-_only_over_you.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/307_fleetwood_mac_-_empire_state.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/308_fleetwood_mac_-_straight_back.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/309_fleetwood_mac_-_hold_me.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/310_fleetwood_mac_-_oh_diane.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/312_fleetwood_mac_-_wish_you_were_here.mp3 sent 61993245 bytes received 289 bytes 17712438.29 bytes/sec total size is 2596551439 speedup is 41.88 

Alternative

Another reason this is happening is because of the use of the -a switch. -a includes a family of switches:

 -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) 

Instead of using -a you could use the individual switches and forgo having to use the --no-OPTION's.

These are the individual options included with -a

 -r, --recursive recurse into directories -l, --links copy symlinks as symlinks -p, --perms preserve permissions -t, --times preserve modification times -o, --owner preserve owner (super-user only) -g, --group preserve group -D same as --devices --specials --devices preserve device files (super-user only) --specials preserve special files 

Doing things this way the above example would become this instead:

$ rsync -rltDvz --delete The\ Fleetwood\ Mac/ /mnt/music/The\ Fleetwood\ Mac/. sending incremental file list Trilogy - 2006/ Trilogy - 2006/Trilogy - 2006 - CD 3/ Trilogy - 2006/Trilogy - 2006 - CD 3/301_fleetwood_mac_-_love_in_store.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/302_fleetwood_mac_-_cant_go_back.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/303_fleetwood_mac_-_thats_alright.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/304_fleetwood_mac_-_book_of_love.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/305_fleetwood_mac_-_gypsy.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/306_fleetwood_mac_-_only_over_you.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/307_fleetwood_mac_-_empire_state.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/308_fleetwood_mac_-_straight_back.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/309_fleetwood_mac_-_hold_me.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/310_fleetwood_mac_-_oh_diane.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/311_fleetwood_mac_-_eyes_of_the_world.mp3 Trilogy - 2006/Trilogy - 2006 - CD 3/312_fleetwood_mac_-_wish_you_were_here.mp3 sent 61993245 bytes received 289 bytes 17712438.29 bytes/sec total size is 2596551439 speedup is 41.88 
14

As already said, the problem occurs whenever you don't have the permission to change file permissions on the destination of rsync. However, you can avoid this error message by using the two additional arguments --no-o and --no-g.

Example:

rsync -ahv --no-o --no-g target/ destination/ 
1
  • 8
    --no-owner and --no-group don't control permissions. You'd want --no-perms for that. If you wanted to avoid trying to change ownerships you'd probably need all three flags. Commented Jan 16, 2018 at 13:22
5

-a is equivalent to -rltpgoD, which stands for:

  • recursive
  • symlinks copied as symlinks
  • preserve times
  • preserve permissions
  • preserve groups
  • preserve owners
  • preserve device and special files (D)

If the destination filesystem (e.g. FAT or NTFS) does not support some of these, simply omit them:

rsync -rltD 
1

I found myself trying to sync "the content" of some directories between two diferent hosts. Let's say: from hostA:/apps/data/ to hostB:/apps/data/

I'm not root user on either and found myself with this problem while executing:

#from hostB rsync -av hostA:/apps/data/ /apps/data/ 

The owner of both directories are the user root:root, but with permissions 777. However, chgrp action on hostB:/apps/data/ failed to chgrp.

If you do not have hidden files of the form .env or directories .data on the root directory to rsync, you can do the same as follow:

#from hostB rsync -av hostA:/apps/data/* /apps/data/ 

You get the same result, without acting over the /apps/data/ directory itself. You get the benefit of keeping all permissions and ownership equal between both systems, except the /apps/data/ itself. In my case is correct.

May this help to someone.

Thanks for your time.

1
  • Adding a * is truly the simplest solution. Thank you, Jordi. Commented Jun 8, 2023 at 18:05
1

I got permission error while using Ansible script.

These options work for me: --no-o --no-g --no-perms

- name: Copying code ansible.posix.synchronize: src: ../../../ dest: "{{ project_path }}" times: no recursive: yes rsync_opts: - "--no-o" - "--no-g" - "--no-perms" - "--exclude=node_modules" - "--exclude=infra" - "--exclude=.git" - "--exclude=package-lock.json" 
0

I had the same issue "rsync: failed to set times on "/home/Samba_Folders/...": Operation not permitted (1)"

I followed the (excellent) advice of Cerin: "It should be noted that you'll get this error even if rsync's user is in the same group a the files. To fix this error, the files must belong to the same user as rsync, not just the group. – Cerin Dec 21 '15 at 21:16"

I changed the owner to the user making the rsync and it worked , solved the problem.

M

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.