tar czvf - ./myfiles/ | pigz -9 -p 16 > ./mybackup.tar.gz
is the equivalent of
tar cvf - ./myfiles/ | gzip | pigz -9 -p 16 > ./mybackup.tar.gz
You're not obtaining a tar.gz
but a tar.gz.gz
, an archive compressed twice, not a compressed archive of compressed files.
That is pointless. Compressed output is not compressible. You won't get any significant space gain by compressing twice. And for extracting, you'd need to decompress twice as well with
gunzip < mybackup.tar.gz | gunzip | tar xf -
Or
gunzip < mybackup.tar.gz | tar xzf -
If you want to use pigz
instead of plain gzip
for the compression, just do:
tar cvf - ./myfiles/ | pigz -9 -p 16 > ./mybackup.tar.gz
Which you can uncompress with tar zxvf mybackup.tar.gz
Also note that you should never have to uncompress a tar.gz
file and store the uncompressed version on disk. The whole point of compressors like gzip
/pigz
, bzip2
/pbzip2
, xz
/pixz
is that they can work on streams, you just insert them in a pipeline.
tar f -
is weird, you could just omit thef
switch, (2) the calls togzip
seem extraneous;tar xz
will take care of unzipping by itself. – dhag Feb 10 '17 at 17:01gzip
are required when usingpigz
in the initial compression. Otherwise thetar
extraction fails. – khaverim Feb 10 '17 at 17:03gzip -d mybackup.tar.gz
will deletemybackup.tar.gz
, causing the followingtar ... mybackup.tar.gz
to fail. – dhag Feb 10 '17 at 17:07z
, since the input to tar is not gzip-compressed anymore :) – dhag Feb 10 '17 at 17:10