Linux – Browsable compressed filesystem archive with full attributes

archivingcompressionlinuxtar

Maybe a variation of the whole question would be: Are there any other archiving tools than tar that preserve Linux file permissions and user/group flags?

I want to create archives of a directory tree on my ubuntu box. The directory trees are large, a first run with tar cvpzf archive.tgz /home/foo/bar yielded a 5GB archive.

I also want to keep all permissions and other flags and special files.

I'm fine with a 5GB archive, however to look inside that archive — since it is a compressed tar archive — the whole 5GB have to be decompressed first! (Or so it appears when opening it with the archive viewer — I'm happy to be corrected.)

So I need a way to "backup" a directory (tree) while preserving full filesystem attributes and right and creating an archive with an "index" that hasn't to be decompressed for browsing its contents.


Edit: Specifying what I think of as an archive, after Whalley's answer :

An archive is either a single file, or a (small) set of files that carries full and complete information within this file/s. That is, it can live on any filesystem (size permitting), it can be burnt onto a DVD, you can split it (after which the point of this question is really lost – but still), …

Best Answer

Do you know about tar's t function for printing out the contents of the archive? You can use it on a gzip compressed archive like this:

tar ztvf archive.tgz

And it will print out the files in a long list like format including timestamps and sizes. It turns out that if you use two v options when creating the archive that it will long list out the files (instead of just plain listing them) as it adds them to the archive, so you can do something like this to auto create an index while you're backing up in one go:

tar cvvpzf archive.tgz /home/foo/bar > archive.tgz.index

Note the use of two v options. Many other commands allow you to increase verbosity this way (ssh for example).

Related Question