yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] KaMyKaSii:
"tar" is a linux command and you are on Windows. You can use 7-zip to extract it

Edit: I just realized that the tar command is recognized but the file is not, probably your backup.tar is corrupted or needs some more work before it can actually be extracted
[Android Software/Hacking General [Developers Only]] Dawberg:
Nope, i have a data backup from Helium, I did

java -jar abe.jar unpack backup.ab backup.tar

Got a tar archive, but 145 kb less then the original .ab file, now I'm trying to extract the tar by doing

tar -xvf backup.tar

And that's what It gives me every time

opened it with 7zip, and that's what I see

7zip screenshot
[Android Software/Hacking General [Developers Only]] scandiun:
Helium backup are different format from "standard" adb backup. I would try helium-backup-extractor to extract the backup.ab but that's not guaranteed to work.
[Android Software/Hacking General [Developers Only]] Dawberg:
There should be a bug in that program, because when I try to go with hbe

java -jar hbe.jar -tar backup.ab

java -jar hbe.jar -force backup.ab

then it gives me this
[Android Software/Hacking General [Developers Only]] scandiun:
Ok download any hex editor like HxD and open the ab file with it to see what's at the beginning of the file.
[Android Software/Hacking General [Developers Only]] Dawberg:
Thta's the screenshot of that file in HexEditor

https://ibb.co/rFW3sqk
[Android Software/Hacking General [Developers Only]] scandiun:
Certainly it's an Helium Backup. You can get more information about it with:

java -jar abe.jar -debug info backup.ab

It will throw you that the backup is compressed, however, by the looks of the screenshot it's not, since you can already see the plain text "_manifest" inside where the app name is. So Helium is not defining properly the backup type. I recomment you to file a bug to the helium developer to see if the developer can help you.
[Android Software/Hacking General [Developers Only]] alecxs:
thats not a bug thats a option. restoring is fine
[Android Software/Hacking General [Developers Only]] scandiun:
Did you restore all apps and everything was restored properly?
[Android Software/Hacking General [Developers Only]] alecxs:
https://sourceforge.net/projects/heliumbackupextractor/files
[Android Software/Hacking General [Developers Only]] more_than_hater:
[MENTION=2738944]scandiun[/MENTION] hello. Are there any way i can create .ab directly from .apk? As far as i understand, i need to save .tar archive structure of defualt android backup file. How can i accomplish that?
[Android Software/Hacking General [Developers Only]] alecxs:
there exist adb commands for install apk, no need to convert
[Android Software/Hacking General [Developers Only]] more_than_hater:
i understand that but i

need

to do it this way
[Android Software/Hacking General [Developers Only]] alecxs:
just forget it, its not worth it. this would be a lot of work to study the source code and figure out how to put things together. the tar archive structure is the easy part

http://android.googlesource.com/platform/frameworks/base/+/4a627c71ff53a4fca1f961f4b1dcc0461df18a06

thats what its probably looks like

apps/pkgname/a/ : /data/app/pkgname-1/base.apk
apps/pkgname/obb/: /data/media/0/Android/obb/pkgname/
apps/pkgname/f/ : /data/data/pkgname/files/
apps/pkgname/db/ : /data/data/pkgname/databases/
apps/pkgname/sp/ : /data/data/pkgname/shared_prefs/
apps/pkgname/r/ : /data/data/pkgname/
apps/pkgname/c/ : /data/data/pkgname/cache/
apps/pkgname/ef/ : /data/media/0/Android/data/pkgname/files/
shared/ : /data/media/0/

but there are two files _meta and _manifest i really have no clue where you want to get this infos from

apps/pkgname/_meta = widget ?
metaVersion=
pkgname=
01 ff ed 01 00 00 ?? ??

apps/pkgname/_manifest = ?
manifestVersion=
package=
versionCode=
sdkVersion=
installer=
userApp=
sigsCount=
certKey=

If you really need a backup.ab create one from another phone

adb backup -apk -noobb -noshared pkgname
[Android Software/Hacking General [Developers Only]] scandiun:
Do you have any other device to create the adb backup? You could use Genymotion virtual machine to create the adb backup once you install the apk on it and restore it on the real device.
[Android Software/Hacking General [Developers Only]] more_than_hater:
i have to use nomerous apk's at xiaomi devices which are not allowing adb install command that's why i'm trying to recreate .ab creating process without VM. But, i guess, thats the only option. Or i should invite some senior to provide support at that question :D
[Android Software/Hacking General [Developers Only]] Gidelix:
Restore crashes at sesame - help

Hey there, I just made a backup with everything except system (I put -nosystem there). Then I rooted my phone (OP6), everything went smoothly. But when restoring the backup, everything seems to freeze and then crash when it gets to 'sesame'. I use a Windows PC and am a total coding noob, barely able to use ADB. Could someone here give me a 'noob walkthrough' on how to remove sesame from the ab file?
[Android Software/Hacking General [Developers Only]] alecxs:
tar is a linux command line utility, you can set up windows to get this work (Cygwin) - or you just boot linux from usb flash drive and run the shell script from terminal. In both cases you won't be a noob anymore because you have learned some basics

https://unetbootin.github.io
[Android Software/Hacking General [Developers Only]] nikant:
sorry to interrupt like this but could you please all sign the petition for Google not to deprecate adb backup and restore? http://chng.it/MNGcD2gc4H
[Android Software/Hacking General [Developers Only]] yahya69:
I have two backup.ab files generated by adb --twrp backup. Since restoring them has failed, I'd like to be able to extract them, but abe fails on it, supposedly because the format is different. Does anyone have a suggestion?
[Android Software/Hacking General [Developers Only]] alecxs:
these are twrp backups, not related to backup.ab please look over to bckp2raw thread
[Android Software/Hacking General [Developers Only]] scandiun:
TWRP backups contain either raw images of a given partition or its contents, both in zipped format. What do you want to extract exactly?

Extracting data from a TWRP backup

[RECOVERY] [TWRP] Android system recovery <3e> universal checksum disabler
[Android Software/Hacking General [Developers Only]] yahya69:
Any would be fine. If I had a raw partition image I could mount it as a loop device and then inspect it. But the problem is that I have a single file called backup.ab generated by adb --trwp backup in which the twrp partition backups seem to be wrapped and I have no idea how to unpack it. There is a java tool called abe.jar swirling around the net, but it only handles pure adb backups.
[Android Software/Hacking General [Developers Only]] scandiun:
I see, so it's a disguised file. Would like to see what the beggining of the file looks like. Could you post a picture or hex dump of the first 64 bytes of the file? What is the size of the ab file?
[Android Software/Hacking General [Developers Only]] yahya69:
$ hexdump -n 64 backup-stock.ab

0000000 5754 5052 0000 0000 7774 7473 6572 6d61

0000010 6568 6461 7265 0000 000b 0000 0000 0000

0000020 0003 0000 0000 0000 8839 d724 0000 0000

0000030 0000 0000 0000 0000 0000 0000 0000 0000

0000040

The total size is about 15GB
[Android Software/Hacking General [Developers Only]] alecxs:
off-topic

thought i had already implemented, but seems i never published. if you wait some days i can check my files, i already have a little script somewhere. because it is not related to abe i will post in other thread. or unpack for yourself, just search for the headers (there are multiple partitions concatenated) http://sourceforge.net/p/adbextractor/discussion/general/thread/f96e7701
[Android Software/Hacking General [Developers Only]] yahya69:
Thanks, that would be great! Yours is the only offer so far. And I am surprised that this seems to be so poorly documented. I find a few posts here on xda asking for help on this very topic, but I don't see any answers. Also I looked through the adb source code, but I can't even find the string "twrp". So if you have a script that can unpack such archives, that would be greatly appreciated!
[Android Software/Hacking General [Developers Only]] yahya69:
Now I managed to extract the archives using a tool that a nice person had provided on github. However, in order to make it word, I first had to integrate two more patches by other developers. I now have source code that compiles and works fine on Linux. If anyone wants to have it, please drop me a note. Maybe, I'll put my fork on github, but I am not a programmer, so this might look pretentious.
[Android Software/Hacking General [Developers Only]] scandiun:
In ASCII:

TWRP....twstreamheader..................9.$×....................

This is clearly not adb backup, you put .ab extension to it just for the sake of it, you should use backup.twprab or something like that. There are scripts which claim to be able to extract TWRP "adb" backups, I put you info here:

Extract TWRP backups made with adb

How to extract adb backups made with the --twrp option?

twrp 3.2.1: adb backup --twrp -> adb restore only restores first image (/system)

TWRP 3.1.0 ADB Restore Fails: command is: 'adbrestore' and there is no value

ADB Backup: Fix gzip backup and restore

Twrp extraction

Cannot extract TWRP backup (Unexpected type: twimage)

Extract backup made with adb (with --twrp option)

Twrp backup restore

arifogel/twrpabx
[Android Software/Hacking General [Developers Only]] scandiun:
You can just put the code on pastebin if you don't want to create a Github account, don't worry about that it's nothing.
[Android Software/Hacking General [Developers Only]] yahya69:
I have gone through most of these options and only the final one actually (kind of) worked, but only after applying two patches from other github members. I am surprised that a solution for this is not more readily available, given the wide use of TWRP

---------- Post added at 10:00 PM ---------- Previous post was at 09:57 PM ----------

I actually have a github account (for bug reporting and some minor contributions to Nextcloud documentation and other stuff), so I guess I'll fork arifogel's repository tomorrow and apply the two patches needed to get it working (unless prudy, the other github member who provided one of the patches goes first)
[Android Software/Hacking General [Developers Only]] alecxs:
off-topic

[MENTION=1012949]scandium[/MENTION] default file name is always backup.ab

https://twrp.me/faq/openrecoveryscript.html

usage: adb backup --twrp compress data
[Android Software/Hacking General [Developers Only]] scandiun:
I see, but although Google has removed any reference to "adb backup" or "adb restore" from developer.android.com, there never was such "twrp" option for official adb. It's just something TWRP did on the side to confuse people. Probably TWRP can perform the "official" adb backup, and since they wanted also to support they own format from command line, instead of having you installing another binary on your local (Windows) PC, they just included the TWRP format obfuscated as another adb backup option. They should have done instead, create a fork of adb.exe for windows and call it twrp-bridge.exe or something which they didn't.
[Android Software/Hacking General [Developers Only]] scandiun:
I would be really greatful if you did that for us.
[Android Software/Hacking General [Developers Only]] scandiun:
Probably because TWRP backups only really work 100% if you restore them to the same device, unless you risk to brick your device, so no point in extracting them. Plus those things are for advanced end users/developers and so on and probably most of them already know how to extract it with a couple of commands. For "normal" users you should use Titanium Backup (if you just root your device), which is more oriented towards compatibility between different devices to preserve apps data. TWRP and CWM are more oriented towards managing custom roms and backing up and restoring sytem images and 1:1 backups (which TB doesn't do)
[Android Software/Hacking General [Developers Only]] yahya69:
Actually there is a point in extracting them: When your device has limited storage, when you want to install a different firmware and want to be able to restore the original one later, or more generally when you understand that a backup on the same device as the original isn't really a backup.

I know and use Titanium as well, but this backup was taken as a safety precaution before moving to a different firmware. And that firmware wasn't easily rooted, so Titanium was not an option...
[Android Software/Hacking General [Developers Only]] yahya69:
One of the devs has already done it, so I don't need to.

His code can be checked out from the branch called Img_and_issue4 of his fork. Here is a direkt link to the zipped source.

(don't download the release version 0.1., it doesn't have the fixed).

To get the code to compile you first have to run

autoreconf -vfi

(from the autoconf package)

After that you can do the usual

./configure && make && sudo make install
[Android Software/Hacking General [Developers Only]] alecxs:
thx! nevertheless, its off-topic here and might confuse. consider revise your posts with [HIDE ] spoilers [/HIDE]
[Android Software/Hacking General [Developers Only]] scandiun:
i don't think that's an issue, even more, it's useful.
[Android Software/Hacking General [Developers Only]] Lerkista:
Have tried this, but with this errors:

in make:

libtool: link: g++ -g -O2 -o .libs/twrpabx.exe src/twrpabx.o src/main.o
pandoc --standalone --to man man/twrpabx.1.md > man/twrpabx.1
/bin/sh: pandoc: command not found
make: *** [Makefile:1144: man/twrpabx.1] Error 127

But i see that a twrpabx was generated, so i run it with my backup, and after a lot of text, shows this:

Remaining bytes in backup file: 22507686912
Read 512 bytes
Data header type: twdatablock
Read 1048064 bytes
Wrote 1048064 bytes
Remaining bytes in backup file: 22506638336
Read 512 bytes
Data header type: md5trailer
Read 1048064 bytes
Wrote 1048064 bytes
Remaining bytes in backup file: 22505589760
Read 512 bytes
Corrupt start of data header

it generates a system.ext4.win file of 1.3Gb, my backup.ab original file is 23Gb

Any idea of how to fix it?
[Android Software/Hacking General [Developers Only]] scandiun:
Looks like you don't have pandoc installed on your system. Are you running linux to run the command? Also, probably your backup.ab has "several" partitions, where system.ext4.win is the first one extracted then fails.
[Android Software/Hacking General [Developers Only]] mohitraj.raj:
So after bashing my head for 12 straight hours, here I am. To avoid the trouble of restoring each app manually, I did the "adb backup --twrp" with just the data partition selected. Seemed to go well. Gave a success message too.

But every time I tried restoring it, it went on for whole 1.5 hours each time, and the bash command would complete but phone would still be stuck at restore screen with the bar moving but no update in logs.

So thought of extracting data and putting it back manually, but that too, seems like trouble.

I've tried the twrp extractor, but to no success.

running the below command gives the following response:

$ twrpabx /media/storage/Oneplus/ROMs/backup.ab

Input file: '/media/storage/Oneplus/ROMs/backup.ab'

Read 512 bytes

Corrupt start of backup header

checking the head:

$ head backup.ab

libc: Access denied finding property "libc.debug.malloc.options"

libc: Access denied finding property "ro.debuggable"

libc: Access denied finding property "libc.debug.malloc.options"

libc: Access denied finding property "ro.debuggable"

TWRPtwstreamheader;�%]TWRPtwfilename�,�/	��f:/data/media/0/TWRP/BACKUPS/4b8e20e/2020-03-04--14-18-08/data.ext4.winTWRPtwdatablockD���/property/00407000000000000000000000000140136300052140011613xustar rootroot57 RHT.security.selinux=u:object_r:property_data_file:s0

39 TWRP.security.e4crypt=21DK

/property/004070000000000000000000000000001363000521400115035ustar rootroot/property/persistent_properties01006000000000000000000000000071136300052140016207xustar rootroot57 RHT.security.selinux=u:object_r:property_data_file:s0

/property/persistent_properties010060000000000000000000000053531363000521400161070ustar rootroot

(

persist.vendor.radio.atfwd.starttrue
[Android Software/Hacking General [Developers Only]] scandiun:
use CODE tags to put code please, it's a mess otherwise.
[Android Software/Hacking General [Developers Only]] eltonb:
How can you edit the "_manifest" file inside the adb backup? It only contains random numbers/letters.
[Android Software/Hacking General [Developers Only]] scandiun:
Of course you can, another thing is that you know what you are doing. About those random numbers, you are referring to line 8? Probably that's the signing certificate, the other previous lines are plain text. In fact the whole _manifest is plain text. Do not mistake the _manifest from adb backup with the AndroidManifest.xml inside apk files. That AndroidManifest.xml will be present inside the apk which can be inside the adb backup as well if you selected -apk flag.
[Android Software/Hacking General [Developers Only]] eltonb:
Thanks for the response. I tried deleting a file inside a backup. As a result dhe backup didn't work anymore, so for a moment i thought the numbers/letters were encrypted content of the backup which needed to be changed in order for the modification to work.
[Android Software/Hacking General [Developers Only]] cash_h:
Depends what file it is, files inside the backup need to be in same order, trailing slash, and so on. It's better done with Linux.
[Android Software/Hacking General [Developers Only]] eltonb:
Yeah, i tried with a hex editor and it worked! PeaZip messed the file order. Thnx!
[Android Software/Hacking General [Developers Only]] scandiun:
With hex editor? How?
[Android Software/Hacking General [Developers Only]] eltonb:
I was trying to delete the file in the first pic using PeaZip, but in doing so the backup wouldn't restore. So i deleted the whole block related to that file in hex and suprisingly it worked.
[Android Software/Hacking General [Developers Only]] scandiun:
I see, you removed from the tar archive the entire block which represents the file to be removed. You did well :good:
[Android Software/Hacking General [Developers Only]] .::Alien::.:
Can I have the exact adb command needed to backup app data of a single app.
[Android Software/Hacking General [Developers Only]] alecxs:
you need pkgname for app. if you share app from google play it is the part of url play.google.com...details?id=<pkgname>

adb backup -apk -f angrybirds.ab com.rovio.angrybirds

leave password empty and just confirm backup
[Android Software/Hacking General [Developers Only]] .::Alien::.:
What about app data only without backing up the apk file.
[Android Software/Hacking General [Developers Only]] alecxs:
just run without flag (or with -noapk)

adb backup [-f <file>] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|nosystem] [-keyvalue|-nokeyvalue] [<packages...>]
adb restore <file>

Note: works only for app with android:allowBackup="true" in AndroidManifest.xml
[Android Software/Hacking General [Developers Only]] scandiun:
Don't use "-apk" or use "-noapk". By default does not backup apk. But I would advise you to back it up, because your app may be removed from Play Store. Most apps are removed over time. You can backup the apk separately using "apk saver" or "apk extractor", or do it with adb backup. Take into account that nowadays there are more than one "apk", depending on android version, manufacturer and architecture, so there's no warranty you apk saved today will work in a smartphone you buy in 5 years.
[Android Software/Hacking General [Developers Only]] anmac1789@gmail.com:
I have 2 samsung galaxy note 2 phones (both models sgh-i317m) . On one of them I backed up using beginner guides.net backup toolkit which was a script for backup/restoring .ab files. However, restoring doesn't work on the new note 2 phone. I usually get a "restore starting" after 5 seconds "restore completed" message but nothing actually got restored. As for the .ab file itself, it is 11 GB in size. Can I use a backup made from one note 2 and restore it to another note 2 ? What is the process ? Thank you
[Android Software/Hacking General [Developers Only]] alecxs:
try to backup a single package (smaller size for testing purposes), check the file size is more than 549 bytes (otherwise fix issues and repeat), then try to restore that file. once restoring works, restore your other backup
[Android Software/Hacking General [Developers Only]] anmac1789@gmail.com:
btw my phone is rooted so I hope that makes a difference
[Android Software/Hacking General [Developers Only]] scandiun:
Which one is rooted? Both?
[Android Software/Hacking General [Developers Only]] anmac1789@gmail.com:
i think both of them are rooted if i remember correctly, before the 2nd one failed
[Android Software/Hacking General [Developers Only]] scandiun:
Just use Titanium Backup.
[Android Software/Hacking General [Developers Only]] alecxs:
Titanium Backup can restore backup.ab?
[Android Software/Hacking General [Developers Only]] scandiun:
I think it can, if not you can extract the ab backup and manually move files to phone, since you are root there's no problem.
[Android Software/Hacking General [Developers Only]] anmac1789@gmail.com:
is titanium backup for PC and how can I do that if my phone is not operating but I have the .adb backup file stored on the computer before it failed.
[Android Software/Hacking General [Developers Only]] DyKey13:
Hi. can you explain exactly how to run the twrpabx on the backup?
[Android Software/Hacking General [Developers Only]] scandiun:
Did you try this?

GitHub - prudy/twrpabx at img_and_issue4

Contribute to prudy/twrpabx development by creating an account on GitHub.

github.com
[Android Software/Hacking General [Developers Only]] DyKey13:
Thanks ! I finally was able to run the script and in fact was the first one that worked for me!
[Android Software/Hacking General [Developers Only]] scandiun:
Great to know. Leave some likes down here.