The tar command can be used to create or extract an archive.
Retain SELinux context
The --selinux option can be used to retain the SELinux context of a file. In this example, example.tar contains the contents of the /etc directory and records the SELinux context of the files in the /etc directory.
tar --selinux -cf /home/john.doe/example.tar /etc
Tar does not have an option to specify the compress level, such as 1 for the least compression, or 9 for the most compression. However, you can create a tar archive, and then use gzip or bzip2 to specify the compression level. For example, a tar archive of the tmp directory can be created, and then the tmp.tar archive can be compressed at level 9.
tar -cf /tmp gzip -9 tmp.tar
The --exclude option can be used to exclude directories from being included in the tar archive. In this example, a tar archive named example.tar is created, and the tar archive will contain everything below the /home directory except for anything at and below /home/john.doe.
tar -cf example.tar --exclude /home/john.doe /home