Recently, I've been backing up a lot of my data, and I noticed that I can save files as .gz
or .tar.gz
, or .7z
and .tar.7z
, etcetera. What are the differences between the normal one and the .tar.*
variant? Which one of them is adviced when making backups?
Ubuntu – What’s the difference between .tar.gz and .gz, or .tar.7z and .7z
backupcompression
Best Answer
If you come from a Windows background, you may be familiar with the zip and rar formats. These are archives of multiple files compressed together.
In Unix and Unix-like systems (like Ubuntu), archiving and compression are separate.
tar
puts multiple files into a single (tar) file.gzip
compresses one file (only).So, to get a compressed archive, you combine the two, first use
tar
orpax
to get all files into a single file (archive.tar
), thengzip
it (archive.tar.gz
).If you have only one file, you need to compress (
notes.txt
): there's no need fortar
, so you just dogzip notes.txt
which will result innotes.txt.gz
. There are other types of compression, such ascompress
,bzip2
andxz
which work in the same manner asgzip
(apart from using different types of compression of course).