Open ghost opened 7 years ago
Looking for a way to do this as well.
Check your file: $ head backup.ab
Twrp has added some things in the beginning. Skipping those with: $ dd if=backup.ab bs=512 skip=3 | head
Got me to a semiworking extraction.
$ dd if=backup.ab bs=512 skip=3 | tar -x
I also am having trouble with this
just saw this show up in the comment section of the stackexchange link posted in the issue (on june 9th): https://github.com/arifogel/twrpabx
it seems to work as advertised. the generated output file causes lots of errors like "tar: Malformed extended header: missing equal sign" when listing/extracting with GNU tar. that's an artifact of the twrp "tar" format though, i think. i just tested and it seems to extract with tar OK even with those error messages. i did not test with a compressed backup.
to build it on linux:
autoreconf -i
./configure
make
thanks @arifogel
@tofurky I'm glad you were able to make use of my tool. FWIW I don't recall getting any tar complaints when I ran at least on my stuff. I'm open to refining the project if you would be willing to toss me some test cases/issues.
@tofurky thanks for sharing this. @arifogel thanks for putting this little program together. Unfortunately, when pointing it at my .ab file (uncompressed), I get "Corrupt start of data header". It outputs a system.ext4.win file which my archive manager complains is corrupt but extraction with the tar command seems to go smoothly. Unfortunately it stops at the system partition.
The reason for the tar
errors is the weird block header format that TWRP uses. Unless the format changed in the last 2 years, this small Python script will convert a TWRP .ab
backup to .tar
: https://gist.github.com/AlD/cb443fe4ba152e1de8a42fa72721552b
The reason for the
tar
errors is the weird block header format that TWRP uses. Unless the format changed in the last 2 years, this small Python script will convert a TWRP.ab
backup to.tar
: https://gist.github.com/AlD/cb443fe4ba152e1de8a42fa72721552b
this simple script helps a lot! thank you! and of course, it works!
Here's how I extracted my multi-partition ADB / TWRP backup when nothing else worked:
Hopefully these shoddy, hastily written instructions can help someone else in the future.
I have a TWRP backup of my data partition @unilock what should I select from the begin to the first system.ext4.win??
Is there a new way to extract the data? I tried @unilock guide and also @AlD python script but without success. I have a backup.ab file with several partitions. In both ways I get a tar file but inside the tar file is just the backup.ab and I can't unpack it due to a checksum error.
@unilock thanks for the video, I really made a mistake and selected the wrong block. But I may have strange backups, but I have "TWRP....twfilename" only once in my *.ab files. In my understanding, I wouldn't remove anything in this case? But this will lead to tar issues and the Python script runs in a never-ending loop. I have 2 backups, one has only the data partition, the other one system, boot, recovery, vendor and data. During the conversion to a tar file, I don't have the case of "TWRP\x00\x00\x00\x00".
@ChrizZz90 If you have a backup containing only the data partition, I believe you should only need to run twrp2tar, without deleting anything in the backup. But it sounds like you already tried that, so I'm not sure where to go from there.
indeed, I tried that already. Same today, just with python3 and some minor changes that print is working with python3. Converting my 30gb backup takes 20min but the script is in an endless loop. I need to stop the script manually but the tar file is corrupt after that. I just have a lib folder and the AndroidManifest.xml in the tar file.
I have TWRP adb backup with all partitions but I only have two TWRP....twfilename for vendor and data however when I restore this update it also contains boot efs and (I hope) system. Why do you think is that? I would like to extract system or at least make sure it's actually there!
The intent of adb backup, if you want to restore individual partitions, you should backup only that partition over adb backup and name the file appropriately.
@sandros87 I'm not familiar with the way TWRP creates backups, but perhaps boot
(ramdisk?) and efs
("Encrypted File System" - stores unique device identifiers) are stored differently than the ext4 partitions? Not sure about system
though, that should be stored as ext4... maybe your backup doesn't include it?
In any case, you could do a text search for "system" in your TWRP backup file, or try restoring the backup on a spare phone with TWRP.
I wrote a short python script to extract files/image from a mutli partition TWRP backup file. It isn't especially robust, so there are probably backup files that it will fail on, but it might be a good starting point for someone else who comes across this thread looking for help.
https://gist.github.com/jerrykan/b3b2f7f43b5e1d4d5b5198748be16bb2
The extracted files were just TAR files.
I have a Samsung Galaxy S2 GT-I9100 smartphone with LineageOS and TWRP. Every week I make a backup with the following command:
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? There are a number of tutorials online that use dd/tar/openssl, but they don't work when using the --twrp option.
I previously asked this question on XDA Developers and on Stack Exchange without success.