1835204 Members
3116 Online
110077 Solutions
New Discussion

gzip and tar together

 
Ho_5
Advisor

gzip and tar together

Do you who how can I tar and gzip a directory in one syntax??

For example I want to tar and gzip the /backup_file directory.

thanks

//john
7 REPLIES 7
Massimo Bianchi
Honored Contributor

Re: gzip and tar together

For example

cd /backup_file
tar cvf - * | gzip -9 > /FULL_PATH/stuff.tgz

Massimo
T G Manikandan
Honored Contributor

Re: gzip and tar together

tar cvf - | gzip > name.tar.gz
H.Merijn Brand (procura
Honored Contributor

Re: gzip and tar together

Use GNU tar (also available from my https://www.beepz.com/personal/merijn/ or http://www.cmve.net/~merijn/) and the -z option:

# gtar -czvf /tmp/xx.tgz .

Builtin, fast, and no 2Gb limit. A must-have

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Ralph Grothe
Honored Contributor

Re: gzip and tar together

...and GNU tar has the added goody of being able to pipe through various compressors on the fly, like the -z switch for gzip you can use -j for the better bzip2 compressor (Linux kernels reside usually in this format in /boot), or even any other compressor by the --use-compress-program=PROG
Madness, thy name is system administration
H.Merijn Brand (procura
Honored Contributor

Re: gzip and tar together

But with one *big* difference between -z (gzip) and all the others: gzip is *builtin* in GNU tar (at least when libz was found during compilation), while all other (de)compressions are started as an external process.

So, though -j is documented to do bzip2, it will not do so when the external binary for bzip2 is not in your $PATH, which may turn up a bit of a disappointment :)

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Ralph Grothe
Honored Contributor

Re: gzip and tar together

Of course, I silently assumed bzip2 and the required compression libs to be already installed on the tarer's box.
You know, we who use GNU/Linux at home for private stuff are a bit spoiled as far as tools are concerned :-)
Madness, thy name is system administration
H.Merijn Brand (procura
Honored Contributor

Re: gzip and tar together

That's not called spoiled, but it's called 'smart' :)

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn