Recover corrupt 7z archives

  • Jelle Fresen

    Jelle Fresen - 2010-06-17


    Here's a summary of my questions: How can I extract the uncorrupted files from an archive that has some corrupted blocks, but was encoded without compression? In case that isn't possible, can you help me with coding my own tool?

    • The story -
      Last week I reinstalled the PC of some relatives and we backed up 16 GB of personal data. I needed a quick solution to split all this data over 4 DVD's, so I choose an open source solution and ended with 7-zip. I used no compression, because speed was more important then space. I burned each of the 4 parts to a DVD. Most unfortunately, I didn't for a second think about creating parity recovery volumes (par2 files), something I deeply regret right now. However, after the reinstallation I discovered that one of the brand new DVD's already showed read errors. With the help of the Unstoppable Copier I managed to get the 4 parts from the DVD's, but this included about 1 MB of corrupted data. 7-zip didn't complain when I merged the 4 files together (that is, I extracted the single .7z file that is contained in the splitted volumes). But now 7-zip refuses to do anything with this 16 GB .7z file.
      The file contains irreplaceable data, so it's really important for me to recover as much data as possible.

    • Question 1 -
      How can I recover all files that are not affected by the corruption from this huge file?

    • Question 2 -
      According to wikipedia, 7-zip has "the ability to unpack archives with corrupted filenames, renaming the files as required". What are the most probably reasons that this fails for me?

    • More research -
      Now, I've done some reading and searching about recovering corrupted 7-zip archives, and I understand that it's a really nasty business, since the LZMA encoding uses variable length packets. Still, I think it would be possible to re-sync with the packet headers after the corrupted part. And maybe it's even easier if the archive is created without compression, but I have no knowledge of the 7z file format.

    • Question 3 -
      What is the file format of an uncompressed 7z file? Will it consist of 1 extremely long LZ77 packet?

    • Coding a tool by myself -
      I would try and implement an algorithm myself, but I don't have a clue how to setup a project and start coding. I have some experience with C coding, but not with open source projects, where I tend to get lost in the vast number of files, dependencies and configurations. I also have some experience with python and would prefer to code in that language, since I find that language quite easy. However, the webpage from Joachim Bauch with the python bindings for LZMA seems to be permanently down. I also have considerable Java experience, but I haven't found a Java library which enables intuitive reading/writing of 7z archives.

    • Question 4 -
      In short, this last question basically is: could you help me with setting up two sample projects in one of the mentioned languages, C, Python or Java? One that extracts all files from a valid 7z file without compression, and one that shows how I can change the low-level behaviour of the file readers, so I can try to deal with corrupted data?

  • Igor Pavlov

    Igor Pavlov - 2010-06-17

    Main things to recover .7z archive:
    1) Provide correct sizes and offsets. You can write zeros instead of corrupted data. You can't insert or remove any bytes.
    2) Provide correct header - first 32 bytes (or correct 8 bytes of signature + 24 bytes of Zeros).
    3) Provide correct footer - last bytes (or kilobytes) that contain filenames / sizes and so on.

  • Jelle Fresen

    Jelle Fresen - 2010-06-17

    Hi, thanks for your quick reply.

    With your information I got some new ideas and I'm now getting more and more into the 7z file format. Here are some useful links for other people that need to get under the hood:
    The 7z file format
    A direct link to the java decoder mentioned between the links of the 7zip mainpage.

    Here are the first 32 bytes of the file in hexadecimal format. It seems to be OK, although I haven't verified the CRC by hand, nor verified the 'next header', but the value of the NextHeaderOffset seems plausible (, which is about the size I expect).

    37 7A BC AF 27 1C 00 03
    75 0F FA 11 99 AA 34 05
    04 00 00 00 28 00 00 00
    00 00 00 00 A8 E3 B1 69

    I think your first point is the reason that 7-zip can't read my 7z file. I have failed to mention one thing, which I deemed to be irrelevant, but which as I now see is quite relevant after all. The 3rd part of the split archive was about 100 MB smaller then the previous two, which is quite strange considering that the DVD was completely full and no different then the previous two DVD's. I used another tool to get all the data from the 3rd DVD and lo and behold, I now have a file that has the same size as the previous two. I'm quite confident that my adventure will get a happy end now, without the need to program a new tool, since there was no corruption on the 4th DVD, which apparently contains the filenames / sizes and other metadata.

    Again, thank you very much for your reply.


  • Jelle Fresen

    Jelle Fresen - 2010-06-18

    FYI: I managed to recover nearly all files. Only two images are now lost, but I couldn't care less about so little collateral damage.
    Again, thanks for your help!

    Yours sincerely,
    Jelle Fresen

  • Alex Krenvalk

    Alex Krenvalk - 2010-07-20

    I am fond of cinema. Several weeks ago I downloaded some films from the rapidshare and I started to extract my zip archives with films but something happened and I saw an unknown error. For luck my friend advised me - zip recover. Because of the tool had helped him in a tight situation. It solved my problem too and quite easy.

  • gennadiy design

    gennadiy design - 2010-10-03

    How can I recover all files that are not affected by the corruption from this huge file?

    file recovery manager - try it

    my site

  • pnugiel

    pnugiel - 2010-10-04

    I was really stupid and deleted the source files of a 12 gig 7 zip archive.  All of the utilities don't work.  Is there a way to rebuild it manually (all criticism aside for my stupidity)?

  • Igor Pavlov

    Igor Pavlov - 2010-10-04

    You can try to recover deleted files with this way:
    1) Open root folder in 7-Zip File Manager
    2) Open "\\." item
    3) Open disk partition
    4) Look files in "" folder

    If it doesn't help, describe your problem with more details.

  • Igor Pavlov

    Igor Pavlov - 2010-10-04

    And use latest 7-zip 9.17 beta with admin rights.

  • Ajexpert

    Ajexpert - 2013-12-01


    I do have same problem. Almost a year ago, I archived about 7.5GB of data using 7z and now I am not able to open it.

    Really appreciate any help in this regard.




Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks