Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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), ...

share|improve this question
add comment

3 Answers

You may want to look into fusecompress, which "provides a mountable Linux file system which transparently compress its content. Files stored in this file system are compressed on the fly and Fuse allows to create a transparent interface between compressed files and user applications."

To the user the stored files can be accessed as if they are not compressed.

But if you have the space, why not just copy the directory tree? Simpler.

Another option is to copy the directory trees to a usb drive. That would allow easy access and would give protection from a disk crash.

share|improve this answer
    
Careful with the USB drive - make sure you know what filesystem is on it - they tend to come pre-formatted with a Windows filesystem of some sort, and those don't tend to support unix permissions. –  Michael Kohne Oct 31 '10 at 20:30
    
Simple copy is not an option when you want to make sure the "archive" can be moved around as transparently as possible. (USB stick NTFS file systems etc.) –  Martin Nov 2 '10 at 7:16
add comment

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).

share|improve this answer
    
Interesting idea! –  Martin Nov 5 '10 at 18:43
add comment

I've run into this problem on multiple occasions. Here's what I've figured out.

ZIP
.zip files support unix permissions and symbolic links if created using the zip utility installed on most Linux systems. However, it doesn't support all the extensions supported by tar, such as hard links and extended attributes. But you can extract files from ZIP archives without decompressing the whole archive up to that point first, so that's a win.

SquashFS
If you're looking for a mountable compressed read-only filesystem, the top contender is currently SquashFS. But there's a catch... well, a few catches, really. Specifically:

  • SquashFS is relatively new, and not as widely supported as tools like tar.
  • There are two on-disk formats out there produced by two different versions of the tool which are not compatible with each other. Make sure you get the right one.
  • There is no FUSE driver -- you need in-kernel support for your version of squashfs in order to mount images.
  • The supporting tools (mksquashfs and unsquashfs) are fairly simple and don't support the wide range of options you see with tar.
  • There's not a lot of documentation.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.