I have a bunch of tarball backups which I just restored onto my new Windows 8.1 + Cygwin system using GNU tar:

zsh$ for file in **/*.tgz; do tar xvzf $file; done

To my surprise a lot of these extracted files were corrupt. I tried replacing GNU tar with BSD tar and repeated the process, but the same files were still corrupt.

Then I tried extracting them with WinRAR, and they turned up just fine. Does anybody know what's going on?

  • 1
    Is there any pattern to the corruption (line endings, files too small, etc.)? Do you know what program created the archives (and on what platform)? – Mikel May 27 '14 at 5:33
  • Can you do a diff -u <(od -An -vtx1 < f1) <(od -An -vtx1 < f2) where f1 and f2 are the same file but extracted with tar and winrar? – Stéphane Chazelas May 27 '14 at 6:28
  • @StephaneChazelas actually the only corrupt files I can find are .otf and .mp3 so I'm not sure what good a diff would do. What I said to @Mikel earlier about the text files was a false alarm. – Mark Boulder May 27 '14 at 6:54
  • 2
    The tar format has gone through a few iterations and supports vendor specific tags/extensions. With what commands were these .tgz created in the first place? – Anthon May 27 '14 at 7:05
  • Just tar czf $file.tgz $folder – Mark Boulder May 27 '14 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.