Page 1 of 1

Rsync: Preserving times/permissions: Operation not permitted

Posted: Thu May 05, 2016 4:24 pm
by peter_b
[PROBLEM]
I'm running BASH scripts to move files around in an archive.
Of course, they shouldn't run as root - but when I try to preserve permissions/ownership/times for the transferred files, I sometimes run into the problem that e.g. rsync, mv, chmod throw a warning, saying "Operation not permitted" :(

Here are some example warning messages:
rsync: failed to set times on "xxx": Operation not permitted (1)
mv: preserving times for `xxx': Operation not permitted
mv: preserving permissions for `xxx': Operation not permitted
chmod: changing permissions of `xxx': Operation not permitted

[SOLUTION]
In my case, the files' owner was someone else. I just had read/write access by group rights.
This is not enough to change the timestamp and/or ownership.

When I ran my scripts using "sudo -u USERNAME", where "USERNAME" is the owner of these files, it works correctly.

This applies at least to the following commands:

Code: Select all

$ cp -av
$ rsync -a
$ mv
$ chmod
:D