I'm trying to sync data to a NFS share while preserving timestamps.

Original file:

-rw-rw-r-- 1 simon simon 1554756 Apr 18  2017 IMG_0578-Bearbeitet.jpg

Used rsync options are -avh --progress.

While copying I got warnings like

rsync: chgrp "/media/simon/.../.IMG_0578-Bearbeitet.jpg.dXOTKi" failed: Operation not permitted (1)

After the action the file metadata is as follows

-rw------- 1 www-data www-data 1554756 Dez  6 00:59 IMG_0578-Bearbeitet.jpg

I suspect, chgrp fails because the NFS drive is mounted so that user and group is always set to www-data (options of the nfs share are (rw,sync,all_squash,anonuid=33,anongid=33,no_subtree_check)).

I find it now weird that

  1. There is no error message about the owner that can't be changed too
  2. As a side effect the time was also not preserved

If I omit the -g from the rsync options like -rlptoDvh --progress (everything from -a except -g), then I get no errors and as a result

-rw-rw-r-- 1 www-data www-data 1554756 Apr 18  2017 IMG_0578-Bearbeitet.jpg

So exactly what I wanted.

What explains these two for me unexpected behaviours?

By the way, omitting just -o does not give anything and results in the same behaviour as with full -a.

  • Are you running rsync as root?
    – Kusalananda
    Dec 6, 2019 at 7:31
  • No I'm running it under user simon without sudo, so the original owner of the files.
    – Simon Lenz
    Dec 6, 2019 at 14:41

1 Answer 1


You are triggering this code in rsync.c:

if (am_root >= 0) {
        uid_t uid = change_uid ? (uid_t)F_OWNER(file) : sxp->st.st_uid;
        gid_t gid = change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid;
        if (do_lchown(fname, uid, gid) != 0) {
                /* We shouldn't have attempted to change uid
                 * or gid unless have the privilege. */
                rsyserr(FERROR_XFER, errno, "%s %s failed",
                    change_uid ? "chown" : "chgrp",
                goto cleanup;

As you may see from this code, which tries to set the owner and group of the destination file, if it fails to modify the files ownership, it skips the rest of the function (with goto cleanup;). The skipped bits of the function handles setting extended attributes, timestamps, ACLs and other meta data.

A similar skip is done when failing to set other data (failing to set timestamps will skip setting file permissions).

As to why it's complaining about setting the group rather than the owner, I'm not entirely sure as it should complain about chown if change_uid is non-zero in the code.

  • Interesting, but it doesn't completely explain the behaviour. I'm not running rsync as root. It looks like then the quoted code isn't executed at all. And I still wonder why I get no error message with just -o. The chown should also fail. But this skipping behaviour explains why the timestamp is not touched when ownership fails. Thanks for that already!
    – Simon Lenz
    Dec 6, 2019 at 14:39

You must log in to answer this question.

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