For me it’s always a mystery when a LineageOS update fails, however one thing is for sure: it’s always when you didn’t made any backup before
So, my first challenge was to recover my data !
My last TWRP backup was on February 2021 (actually just before switching from LOS17.1 stable to LOS18 unofficial), and I wanted to recover the app data that get populated in the meantime (e.g. Whatsapp conversation of the last 3 months).
- Before wiping (factory reset) and fresh-installing
lineage-18.1-20210514, I made a TWRP backup of the corrupted system.
- So my data should be somewhere in the TWRP-image, in a file
data.ext4.win000 data.ext4.win001 etc.
- I checked before that it is possible to repopulate the Whatsapp conversations once the databases are extracted from data/data/ , and indeed it’s possible, see tutorial here.
- The file
data.ext4.win00* is a tar archive, so it should be as easy as 7zip > Extract here or
tar -xf in terminal, no? Actually no! Even if I could see which files where inside the archive with 7zip, once extracting I got only error messages, like
malformed extented header : missing equal sign
- So I searched for this error and I found two blog posts here and here, explaining basically that the file is not a standard tar archive as TWRP added some stuff to it:
It turns out, my backup files (made with TWRP 3.2.1) actual have two entries for every file in the tar archive. The first entry seems to only store selinux information, which TWRP probably uses during its full system restore process.
- The tar header starts with the filename at line
- The header is 512 bytes long (
200 in hex), and the “file contents” begin at line
- Tar archives support multiple entries for one filename as “links”. The link type is at byte offset 156 in the header. For this entry, that link type is
x (last non-null byte on
00001290), which isn’t in the tar standard and is likely the problem for untarring programs.
- In those blogs they mentioned some python script to clean the extra stuff, or some command line with
dd , but honestly it started to be too long/complicated for me.
- Then I found here a solution out-of-the-box :
This isn’t exactly the answer your looking for, but if you want to restore the data on to a different phone, the easiest way is to just copy the with TWRP backups on to the new phone (same location too /sdcard/TWRP/BACKUPS), and then use Titanium Backup to restore from it. In Titanium, click on Menu - Extract from Nandroid backup.
- Awesome! I’m using Titanium for more that I can remember (actually from the first time I got an Android phone) and I wasn’t aware of such a nice feature.
- Actually this feature is only for the “donation” version of Titanium, but as I said I’m using it for so long that I don’t mind paying 5€ for unlocking the full version.
- And it worked flawlessly! All app data were restored from the TWRP corrupted archive
I’m happy. Having this kind of problems can be painful but at the end it’s a good opportunity to lean while solving it