ADB BACKUPS
############
 
* Note Citing my sources throughout the article.
 
Backing up and Restoring
========================
Good articles: http://forum.xda-developers.com/showthread.php?t=1420351
Another good article: http://www.thesuperusersguide.com/adb-backup–restore.html
 
First install  Android SDK Platform Tools on windows usually it goes to “C:\android-sdk-windows\platform-tools”
 
On phone enable USB Debugging from SEttings->Developer Options
 
Open explorer and go to “C:\android-sdk-windows” directory and hold shift while right clicking on “platform-tools” and select “open command window here”, thats a good shortcut to open a cmd window into any folder
 
adb devices
 
To see connected devices
 
if you see your device
 
BACKING UP
———-
 
adb backup -apk -shared -all -f C:\outputfile.ab
 
* NOTE ABOUT FLAGS (excerpts from: http://forum.xda-developers.com/showthread.php?t=1420351)
-apk|-noapk: This flags whether or not the APKs should be included in the backup or just the apps’ respective data. I personally use -apk just in case the app isn’t available in the Market, so that I don’t have to go hunt it down again. The default is -noapk.
-shared|-noshared: This flag is used to “enable/disable backup of the device’s shared storage / SD card contents; the default is noshared.”, which for the Nexus I would certainly flag to -shared, but from my test, it did not restore all of the contents of my internal storage, so I recommend backing up music, pictures, video, and other internal storage items manually, just to be on the safe side. The default is -noshared.
-all: This flag is just an easy way to say to backup ALL apps. The packages flag (further on) can be used to choose individual packages, but unless you’re just wanting to backup a specific application, use -all for a full system backup.
-f <filename>: specifies file save location on the computer
 
Now on phone you should see a screen, if you see a lock screen then unlock it.
 
Click backup now or set a password and backup. Note if you set a password using ADB Extractor becomes a hassle and using simple linux tools like openssl becomes impossible (at least undocumented on the web as far as I can tell, besides looking through the source code of android or the abe.jar)
 
RESTORING
———-
 
adb restore C:\backup\mybackup.ab
 
Then look at phone, unlock the lock if you need to and if you need to type in a password then type it in.
 
How to Extract ADB backups With ADB Extractor & Manual extraction with openssl
===============================================================================
 
LINK: http://sourceforge.net/projects/adbextractor/
* Download the zip file.
* Extract the abe.jar
* JUST COPY abe.jar INTO DIRECTORY WHERE YOU HAVE adb backup .bak or .ad OR .whatever FILE AS LONG AS IT WAS MADE WITH adb backup (OR MAYBE AS LONG AS IT WAS JUST MADE WITH adb)
* JUST OPEN CYGWIN INTO DIRECTORY AND RUN:
# java -jar abe.jar unpack backup.bak backup.tar [password]
 
* Prerequisties for above method:
– To test run “java -jar abe.jar” then just CONTROL-C, if works good you will have no output, if works bad you will have errors as seen below.
– openjdk-7-jdk (openjdk-6-jdk causes errors)
– check vurrent active version with “java -version”
– if output of “java -version”:
—- java version “1.7.0_21” GOOD
—- java version “1.6.0_27” NOT GOOD
Error message when running the program looks like this:
Exception in thread “main” java.lang.UnsupportedClassVersionError: org/nick/abe/Main : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:266)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
 
* Note running the program with the incorrect prereqs doesnt hurt the source file
 
* Note if there is a password make sure you have the following:
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\
– For Linux or BSD:
/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/
 
Another way to extract with abe.jar, only works with none password encrypted backups:
 
# dd if=nexus7.ab bs=24 skip=1 | openssl zlib -d > nexus7.tar
Get pv to get a progress bar 🙂 LINUX: “apt-get install pv” or CYGWIN:”apt-cyg install pv”
# dd if=nexus7.ab bs=24 skip=1 | pv | openssl zlib -d > nexus7.tar
The above pv command just provides speeds but no measure of when the task will be complete (no ETA and no PERCENTAGE PROG BAR), below method has a PROG BAR because it gets the size in bytes into “pv -s” argument
# SRC1=”nexus7.ab”; dd if=${SRC1} bs=24 skip=1 | pv -s `stat –format=”%s” ${SRC1}` | openssl zlib -d > nexus7.tar
 
Sidenote about packing the file as written in the forum:
# dd if=nexus7.ab bs=24 count=1 of=gta3.ab ; openssl zlib -in gta3.tar >> gta3.ab
* “dd if=nexus7.ab bs=24 count=1 of=gta3.ab” that portion of the command gets the 24 byte header, as its the same on all adbs (or most), then the next portion appends the openssl zlib encrpyted file
WITH PROGRESS BAR CAN GET SPEED
# dd if=nexus7.ab bs=24 count=1 of=gta3.ab ; openssl zlib -in gta3.tar | pv >> gta3.ab

2 thoughts on “ANDROID – ADB Backup/Restore- ADB Extractor (abe) – Extracting adbs with openssl

  1. If you have both Java 7 and 8, you may need to add the JCE files for Java 8. (I suppose you could also just disable the Java 8 runtime temporarily.)

    http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

    Thank you so much for this article… I did not want to go through the hassle of spinning up a VM just to extract 1 3.5GB file.. only reason I had a password was because of the weird issues with 4.4.2 and platform tools 1.0.32 (many users reported setting a password allowed backup to complete and not finish immediately with 0KB backup.ab file. Fix for me was just to use the 1.0.31 version of adb.)

Leave a Reply

Your email address will not be published. Required fields are marked *