What is an android adb backup?
An adb backup is a file with ab extension, generated by android's backup manager when we request it via adb shell. This allows you to backup some data of the phone, but is not a replacement of a clockworkmod backup:
- Each application files may be backed up or not depending on its policies. In some cases, the apk itself is never backed up even if requested.
- Usually for restoring an application's data it requires you to have it installed first.
- Inside an ab file is a tar file, which contains files and folders in a certain order. You have you respect that order in order to create a valid tar file.
- Inside the tar file, directories must not have trailing slash, for that reason star or equivalent has to be used.
- There are some bugs present in the android source code.
You can use java or perl, although with perl can be more complicated because requires downloading some modules from cpan and some ssl headers.
To know more information about types of android backups:
[Guide] Types of Android backups
Software needed
The best way to get all software needed is to use a unix-like operating systems, like Linux, OS X or BSD, since we should extract the files on a filesystem that preservers file permissions and owners and repack the tar archive. Furthermore some tools like star are easier to get for linux. In such cases, using Virtualbox or VMWare Workstation is highly recommended.
Java 7 or higher
Perl
star
star is required since GNU Tar does not allow storing directories without trailing slash. You can get the ubuntu version 1.5 here. For windows or Cygwin I haven't found it yet, if exists.
Android Backup Extractor
Android Backup Extractor is the java application that does all the job. It includes the perl scripts.
How it works, better with an example
I will use an example to demonstrate how it works, with java version. If you like to use perl, just grab the perl scripts and is nearly the same.
This is extracted from the readme file, and will extract a whole adb backup and repack only the data for the game Grand Theft Auto III for android.
1) Convert the original adb backup to tar format:
2) Extract the contents of the tar archive. This should be done on a filesystem where the permissions of the files inside the tar are preserved, for example using linux, mac or bsd. Up to two folders may appear, apps and shared:
3) Make a list of all the contents of the original archive in the order they are archived:
4) Create a new list only with the files and folders you want, in proper order. For example for the GTA 3 (you can try savegames instead of all data):
5) Create the new tar archive. The directories stored on tar shouldn't contain trailing slashes, so I use star instead of tar:
6) Create the adb backup from the tar archive. Password is optional:
Note: if the backup is not encrypted zlib can be used instead for both unpack and pack the ab archive:
- Quick unpacking:
- Quick packing:
Links
Android Backup Extractor (@ Sourceforge)
Android Backup Extractor (@ GitHub)
Documentation at Blogspot
[Guide] Types of Android backups
Perl scripts to encrypt/decrypt adb backup files
[GUIDE] Full Phone Backup without Unlock or Root
Related adb backup and restore bugs:
Issue 28303: adb backup doesn't respect -noshared flag
Issue 32830: adb restore errors not displayed on device
Issue 34311: Galaxy Nexus gets stuck when restoring adb backup
Issue 25780: BackupManager causes reboot when BackupAgent missing
An adb backup is a file with ab extension, generated by android's backup manager when we request it via adb shell. This allows you to backup some data of the phone, but is not a replacement of a clockworkmod backup:
- Each application files may be backed up or not depending on its policies. In some cases, the apk itself is never backed up even if requested.
- Usually for restoring an application's data it requires you to have it installed first.
- Inside an ab file is a tar file, which contains files and folders in a certain order. You have you respect that order in order to create a valid tar file.
- Inside the tar file, directories must not have trailing slash, for that reason star or equivalent has to be used.
- There are some bugs present in the android source code.
You can use java or perl, although with perl can be more complicated because requires downloading some modules from cpan and some ssl headers.
To know more information about types of android backups:
[Guide] Types of Android backups
Software needed
The best way to get all software needed is to use a unix-like operating systems, like Linux, OS X or BSD, since we should extract the files on a filesystem that preservers file permissions and owners and repack the tar archive. Furthermore some tools like star are easier to get for linux. In such cases, using Virtualbox or VMWare Workstation is highly recommended.
Java 7 or higher
- Oracle Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 if you are going to work with password encrypted backups.
You need to install the files local_policy.jar and US_export_policy.jar under jre's lib/security folder, for example:
- For Windows:- C:\Program Files\Java\jdk1.7.0_09\jre\lib\security\
- C:\Program Files\Java\jre7\lib\security\
- C:\Program Files (x86)\Java\jdk1.7.0_07\jre\lib\security\
- C:\Program Files (x86)\Java\jre7\lib\security\
/usr/local/jdk1.7/jre/lib/security/
/usr/lib/jvm/java-7-openjdk-*/jre/lib/security/
/usr/local/openjdk7/jre/lib/security/
- For OS X:- /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/security/
Perl
- Perl is available for several operating systems
- libssl or openssl headers. If you are using Linux or Cygwin is much more easier
- cpan modules required by use functions
star
star is required since GNU Tar does not allow storing directories without trailing slash. You can get the ubuntu version 1.5 here. For windows or Cygwin I haven't found it yet, if exists.
Android Backup Extractor
Android Backup Extractor is the java application that does all the job. It includes the perl scripts.
How it works, better with an example
I will use an example to demonstrate how it works, with java version. If you like to use perl, just grab the perl scripts and is nearly the same.
This is extracted from the readme file, and will extract a whole adb backup and repack only the data for the game Grand Theft Auto III for android.
1) Convert the original adb backup to tar format:
Code:
java -jar abe.jar unpack nexus7.ab nexus7.tar <password>Code:
tar -xvf nexus7.tarCode:
tar -tf nexus7.tar > nexus7.listCode:
cat nexus7.list | grep com.rockstar.gta3 > gta3.listCode:
star -c -v -f gta3.tar -no-dirslash list=gta3.listCode:
java -jar abe.jar pack gta3.tar gta3.ab <password>- Quick unpacking:
Code:
dd if=nexus7.ab bs=24 skip=1 | openssl zlib -d > nexus7.tarCode:
dd if=nexus7.ab bs=24 count=1 of=gta3.ab ; openssl zlib -in gta3.tar >> gta3.abAndroid Backup Extractor (@ Sourceforge)
Android Backup Extractor (@ GitHub)
Documentation at Blogspot
[Guide] Types of Android backups
Perl scripts to encrypt/decrypt adb backup files
[GUIDE] Full Phone Backup without Unlock or Root
Related adb backup and restore bugs:
Issue 28303: adb backup doesn't respect -noshared flag
Issue 32830: adb restore errors not displayed on device
Issue 34311: Galaxy Nexus gets stuck when restoring adb backup
Issue 25780: BackupManager causes reboot when BackupAgent missing