如何从损坏的 .tar.gz 存档中恢复文件?
我的 .tar.gz 存档中有大量文件。 使用命令检查文件类型
file SMS.tar.gz
会给出响应
gzip compressed data - deflate method , max compression
当我尝试使用 Gunzip 提取存档时,经过一段延迟后,我收到消息
gunzip: SMS.tar.gz: unexpected end of file
是否有任何方法可以恢复存档的一部分?
I have a large number of files in a .tar.gz archive. Checking the file type with the command
file SMS.tar.gz
gives the response
gzip compressed data - deflate method , max compression
When I try to extract the archive with gunzip, after a delay I receive the message
gunzip: SMS.tar.gz: unexpected end of file
Is there any way to recover even part of the archive?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恢复是可能的,但这取决于导致损坏的原因。
如果文件只是被截断,那么获取部分结果并不太难; 只要运行
尽管最后出现错误,但
就会给出一些输出。 如果压缩文件有大块缺失块,坏块之后基本就没救了。
如果压缩文件以较小的方式系统性损坏(例如,以 ASCII 模式传输二进制文件,这会破坏整个文件中的回车符和换行符),则可以恢复,但需要相当多的自定义编程,这确实是值得的如果您绝对没有其他资源(没有备份)并且数据值得付出很多努力。 (我已经成功完成了。)我在上一个问题中提到了这种情况。
.zip 文件的答案有所不同,因为 zip 存档有多个单独压缩的成员,因此还有更多希望(尽管大多数商业工具相当虚假,它们通过修补 CRC 来消除警告,而不是通过恢复良好的数据)。 但您的问题是关于 .tar.gz 文件,该文件是一个包含一个大成员的存档。
Recovery is possible but it depends on what caused the corruption.
If the file is just truncated, getting some partial result out is not too hard; just run
which will give some output despite the error at the end.
If the compressed file has large missing blocks, it's basically hopeless after the bad block.
If the compressed file is systematically corrupted in small ways (e.g. transferring the binary file in ASCII mode, which smashes carriage returns and newlines throughout the file), it is possible to recover but requires quite a bit of custom programming, it's really only worth it if you have absolutely no other recourse (no backups) and the data is worth a lot of effort. (I have done it successfully.) I mentioned this scenario in a previous question.
The answers for .zip files differ somewhat, since zip archives have multiple separately-compressed members, so there's more hope (though most commercial tools are rather bogus, they eliminate warnings by patching CRCs, not by recovering good data). But your question was about a .tar.gz file, which is an archive with one big member.
您确定这是一个 gzip 文件吗? 我首先运行“file SMS.tar.gz”来验证这一点。
然后我会阅读 gzip 恢复工具包页面。
Are you sure that it is a gzip file? I would first run 'file SMS.tar.gz' to validate that.
Then I would read the The gzip Recovery Toolkit page.
这是我们遇到的一种可能的情况。 我们有一个 tar.gz 文件无法解压,尝试解压时出现错误:
我发现该文件可能最初是通过非二进制 ftp 连接上传的(我们不确定) )。
使用 unix
dos2unix
实用程序解决方案相对简单,它成功了!
这是一个很小的可能性,也许值得一试——它可能会帮助那里的人。
Here is one possible scenario that we encountered. We had a tar.gz file that would not decompress, trying to unzip gave the error:
I figured out that the file may been originally uploaded over a non binary ftp connection (we don't know for sure).
The solution was relatively simple using the unix
dos2unix
utilityIt worked!
This is one slim possibility, and maybe worth a try - it may help somebody out there.