rsync not preserving/transferring extended attributes even though -AX being used on command line - how to run rsync without root user

Solution Verified - Updated -

Issue

  • The issue is that extended attributes, including selinux labels, are not restored after a rsync:

    $ ls -Z test_rsync_src
    unconfined_u:object_r:passwd_file_t:s0 file_with_xattr
    
    $ rsync -aHAX test_rsync_src test_rsync_dst
    
    $ ll -Z test_rsync_dst
    total 0
    drwxrwxr-x. 2 user1 user1 unconfined_u:object_r:user_home_t:s0 29 Jun 29 17:10 test_rsync_src
    
  • From the man of rsync, the extended attributes should be restored with the option X:

           -X, --xattrs
                  This option causes rsync to update the destination extended attributes to be the same as the source ones.
    

Environment

  • Red Hat Enterprise Linux
  • Selinux
  • rsync

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content