Extract TWRP backups made with adb I have a Samsung Galaxy S2 GT-I9100 smartphone with LineageOS and TWRP. Every week I make a backup with the following command:

adb backup -f twrp-20170322.ab --twrp boot data system


I may optionally use the --compress option, too.

Is there a way to extract the twrp-20170322.ab backup file with stardard GNU/Linux command line tools? I will also consider installing extra software if needed, but it must be free (as in freedom).

Links:


https://forum.xda-developers.com/android/help/extract-backup-adb-twrp-option-t3577903
https://github.com/TeamWin/Team-Win-Recovery-Project/issues/898
I have found that TWRP-generated .ab files are different from the normal adb backup files, so the offset is different from normal .ab files. I was able to inspect and extract files using (for example to inspect) the following command:

dd if=backup.ab bs=512 skip=1 | tar ft -


Apparently, the header may be longer, but it should be aligned with 512-bytes boundaries, so just bump the skip= parameter if it can't find it at first.

Note that the file format is defined in twadbstream.h, if you need to dig into this further.