Answer the question
In order to leave comments, you need to log in
Which is better to use gz or bz2 archive type?
I want to make a backup of the system (Debian 10)
What is better to use to save rights, etc.?
Answer the question
In order to leave comments, you need to log in
In linux, it has historically developed to use tar for archiving, this is probably the most versatile tool, it will allow you to save everything plus even what is not needed.
* to save permissions, you need the -p switch
* to save extended attributes, you need the --xattrs switch
* to detect and save information about leaky files sparse the -S switch
* symbolic links will be saved as links by default, the behavior can be changed in different ways by options (for example, store as a file or, for example, when unpacking, try to create a hardlink instead of a symlink, etc.)
You can then pack the resulting tar archive or better in the process, the -a switch will automatically determine the archiver by extension, whatever. Nobody prevents you from creating an archive without saving it, simply by sending it to nowhere at the time of creation:
tar -cjf /dev/stdout . | wc -c
it will compress bzip2 (key j) of the current directory with subdirectories and send it to the wc command, which will simply calculate its size in bytes and display it on the screen. Repeat the command, changing the j key to J (this is xz), z (this is gzip), etc. and compare the resulting sizes (I advise you to try zstd)
ps as an alternative, you can archive not files, but the entire partition, using the partclone set of utilities (supports everything, even something like ntfs), you can create a copy of the partition in which sectors marked as free will not be saved, while the speed of the utility is comparable to dd (and this is generally just sector-by-sector copying) and in most cases allows you to change the size of the partition to which all this will be restored (rarely with ntfs, but there may be problems when reducing)
pps there are still file system features, for example, btrfs has the ability to get as a file, the difference between the specified snapshots created at different times, and apply it later, at least on a different machine... can also be considered a backup tool
In this case (full backups), gzip and bzip2 press a tar file, which is already an uncompressed "archive" of your files with all the attributes (depending on how you set the flags)
So in terms of file permissions and attributes, they are absolutely identical
Subjectively better than gzip
Why can bzip2 is better
Well, in general, total:
1.1. gzip presses faster, bz2 presses harder (all by default). But you have to choose one.
1.2. xz hits the hardest, but you might not wait until retirement.
1.3.. zstd decompresses roughly like gzip (both speed and compression), but decompresses an order of magnitude faster than gzip. But not everywhere is.
2. what is "better" in the characteristics of compressors is missing as a class (although the word best is present in the mana).
3. Compressors have nothing to do with rights.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question