tar & compression

Joe Altman freebsd at chthonixia.net
Fri Jan 18 03:15:36 UTC 2013


On Thu, Jan 17, 2013 at 09:29:55PM -0500, Fbsd8 wrote:
> The man page for tar command says there a 4 different compress types
> you can use, xz, bzip, bzip2 and gzip.

xz uses Lempel-Ziv-Markov chain algorithm.
bzip2 uses Burrows-Wheeler transform.
 
> Which one is the fastest and compresses the most?

Sounds like a case of fast or cheap: choose one.

Or is it fast or expensive? Or maybe it's all just bragging.

OTOH, apropos compression may be instructive:

7z (and related)

> I am using -z option for gzip and it sure is slow.
> Hoping one of the other zip options are better.
> What do you guys use?

Used to use bzip2 and tar. Nowadays I just place files on a big disk
that only runs when I backup my bits.

> Another question about tar is can I have tar create a compressed bkup
> of 2 files and a directory tree all in single tar command?

For directories, I've used this:

tar -cf - -C srcdir . | tar xpf - -C destdir

The tar man page has this:

tar -czf file.tar.gz source.c source.h 

Since anything is a file, it seems to me it would work on a directory
with this:

tar -czf file.tar.gz source.c source.h /path/to/directory

I also note that (since you've mentioned mtree) the man page on tar
provides an example on mtree. Could this be applied to your needs?

Best regards,

Joe


More information about the freebsd-questions mailing list