恢复损坏的 tarball

恢复损坏的 tarball

我手上有一个损坏的 tarball。我的第一次恢复尝试是这样的:

$ tar --ignore-failed-read --ignore-command-error -xf tarball.tar
tar: Skipping to next header tar: Archive contains ‘180738 0’ where numeric mode_t value expected
tar: Archive contains ‘0.445647 -9.’ where numeric time_t value expected
tar: Archive contains ‘.259273 ’ where numeric uid_t value expected
tar: Archive contains obsolescent base-64 headers
tar: Archive contains ‘-0.94874’ where numeric gid_t value expected
tar: text from a text file is here: implausibly old time stamp 1969-12-31 18:59:59
tar: more text file contents are here: Unknown file type 'p', extracted as normal file
tar: Skipping to next header
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

在出错之前,这并没有从 tarball 中提取太多内容。退出状态为 2,tar 手册页称这是一个致命错误。

的文档“gzip 恢复工具包” 建议这样:

cpio -F tarball.tar -i -v

这提取了 1.8G tarball 中的 1.2G,这非常好。它会在终端提示后输入一堆垃圾而停止——它没有打印到屏幕上,就好像我已经输入了它但还没有按回车键一样。

有没有办法做得更好?有没有办法尝试“跳过 tarball 的坏块”?

使用--ignore-zerostar 似乎可以读取整个 tar 文件。

tar -R --ignore-failed-read --ignore-command-error --ignore-zeros -xvf tarball.tar
[...]
block 3670356: ** Block of NULs **
block 3670357: ** Block of NULs **
block 3670358: ** Block of NULs **
block 3670359: ** End of File **
tar: Exiting with failure status due to previous errors

有很多Block of NULs错误,看起来内容可能无法恢复。

答案1

您没有使用tarbutgtar和错误消息:

tar: Archive contains obsolescent base-64 headers

gtar与 20 多年来反复报告的众所周知的错误有关。过去曾进行过源代码更改,从而降低了出现此问题的可能性,但这些更改尚未真正解决gtar.

如果您想检查您的存档,您可以使用包tartest中的内容star,并且可以尝试使用star来提取存档,star -i以防star报告错误。

相关内容