Does tar's z option compress on the fly?

rharder

Do not read this sign.
When using tar (or gnutar or star) does the z parameter compress the data all in one fell swoop or does it tar the directories and then zip it?

The reason I'm wondering is that when I backup my OS X to my Win98 box, my 100baseT network only gets 200K throughput, so if I could compress the data that would help me out.

In other words, if I execute
Code:
% <b>sudo gnutar cpvzf /backup/usr.tar /usr</b>
does that compress the stream across the network (to the /backup mount) or does it tar across the network, read it back from the network, compress it, and write it back across the network?

BTW, has anyone gotten star to compile on OS X? It's supposed to be an ultra-fast tar.

-Rob
 
I have always needed to add the zip (.z) or gnuzip (.gz) after creating the my tar archive. gnutar never gave me all that much in the way of space savings. I had moved most of my things off my original drive to my Indy when I got my 30 GB drive.
 
It does neither of the things you describe but it APPEARS to do #1.

What it does in reality is setup a pipeline so that the gzip binary is transparently called and the final output is sent to the final
destination.

It is equiv to "tar cvf - <directory> | gzip -c </destination/tarball.tar.gz>

 
Originally posted by howardm4
It is equiv to "tar cvf - <directory> | gzip -c </destination/tarball.tar.gz>


The benefit of using the syntax listed above, is you can add additional flags for gzip such as this:

tar -cvf <dir> | gzip -c --best > <dir.tgz>

which gives you the maximal compression out of gzip.

 
Originally posted by howardm4
It is equiv to "tar cvf - <directory> | gzip -c </destination/tarball.tar.gz>


The benefit of using the syntax listed above, is you can add additional flags for gzip such as this:

tar -cvf <dir> | gzip -c --best > <dir.tgz>

which gives you the maximal compression out of gzip.

 
--best is usually a pretty waste of time. The change in compression vs. the
increased runtime isn't worth it.

Just use a better/different tool such as bzip2
 
So when I pipe the tar command to gzip or bzip2 or whatever, does <em>that</em> happen on the fly or does it write the whole tar file to /tmp and <em>then</em> compress it?

-Rob
 
Originally posted by rharder
So when I pipe the tar command to gzip or bzip2 or whatever, does <em>that</em> happen on the fly or does it write the whole tar file to /tmp and <em>then</em> compress it?

-Rob

Yes, it does happen on the fly. This ain't MS-DOS any more. Any decent UNIX filter program will take input on standard input, and write output to standard output; both of these can be connected to a file, but if one program is directly feeding another (pipe), disk is not involved :) (and hasn't been since dawn-a-time, in late sixties, early seventies, previous century)

BTW, not even Windows piping creates intermediate files.
 
You are correct.

It is STDIN to STDOUT when you tar and zip a file.
Everything in unix is a file.
Your tty is no exception.

FYI:
Programs in windows copy to the temp dir then to the location specified.

Windows isnt anywhere near unix. And it never will be.

One thing that I love is that if you run strings on ftp in windows you will see that its a version written for bsd and then ported without credit.
 
Back
Top