tar and rsync: Archive and Preserve SELinux Contexts, Extended Attributes, And ACLs
tar –selinux –acls –xattrs -cvfz file.tgz yourfiles
Where,
–selinux – Save the SELinux context to the archive called file.tgz.
–acls – Save the ACLs to the archive called file.tgz.
–xattrs – Save the user/root xattrs to the archive called file.tgz Please that it archive all extended attributes, including SELinux and ACLs.
-c – Create a new archive called file.tgz.
-v – Verbose output.
-f file.tgz – Archive file name.
-z – gzip.
yourfiles – Create archive called file.tgz from yourfiles
rsync -av -A -X /source/path /dest/path
Where,
-A : Preserve ACL.
-X : Preserve extended attributes/SELinux.
-a : Archive mode.
-v : verbose.