Creating Compressed Archives
In practice, archiving (bundling) and compression (shrinking) are usually done in one step using tar's built-in options.
Gzip Compression (-z)
Use -z to compress the resulting archive using gzip. The filename convention is typically .tar.gz or .tgz.
Create and compress:
bash $ tar -czvf web_backup.tar.gz /var/www/html
Extract and decompress:
bash $ tar -xzvf web_backup.tar.gz
Bzip2 Compression (-j)
Use -j to compress using bzip2. The filename convention is .tar.bz2 or .tbz.
Create and compress:
bash $ tar -cjvf project_v2.tar.bz2 project_B/
Extract and decompress:
bash $ tar -xjvf project_v2.tar.bz2
XZ Compression (-J)
The newer, often most efficient compression method.
bash $ tar -cJvf data.tar.xz data/