Home / SELinux context is not preserved during rsync

SELinux context is not preserved during rsync

The preservation of SELinux context is not maintained during a rsync operation due to the absence of the xattr feature on the target NFS file system. Running rsync with the options -X does not preserve SELinux context and observes apparent errors such as ** security.selinux failed: Operation not supported.

Method 1 - Utilize the tar command with the selinux option

tar --selinux -cvf archive.tar /path/to/files

Method 2 - Backup and restore extended attributes.

getfattr -Rd -m - / > /tmp/all_xattrs

Perform a restore as follows:

cd /
setfattr --restore /tmp/all_xattrs


  • cd to the mounted filesystem.
cd /foo/bar
  • Execute the following command:
touch .is_xattr_supported && setfattr -n user.comment -v 'File created by ReaR to test if this filesystems supports extended attributes.' .is_xattr_supported && getfattr -n user.comment .is_xattr_supported ; find .is_xattr_supported -empty -delete
  • Expected error:
setfattr: .is_xattr_supported: Operation not supported

Leave a Reply