Coolcrab
Coolcrab

Reputation: 2723

Open incomplete tar.gz file

I have a backup of my website that seems to have failed in the download and is incomplete. However there is still a lot of stuff in there. Is there a way to extract the archive to retrieve whatever is inside?

I am on a Mac.

Upvotes: 1

Views: 726

Answers (1)

Mark Adler
Mark Adler

Reputation: 112617

The gzip in macOS will stop as soon at it hits the premature end of the file, and not provide all of the decompressed data it has extracted so far. However, pigz will provide everything it was able to extract. (That is a recent commit, so you'll need to use the linked develop branch.) You can compile pigz and pipe its output to tar:

pigz -d < incomplete.tar.gz | tar -xvf -

The last file, very likely cut off in the middle, will be partially extracted with the error:

x somefilename: Truncated tar archive

All of the files preceding that one will be extracted correctly.

Upvotes: 2

Related Questions