Backup & Restore Android Apps Using ADB

Android is an interesting platform for a number of reasons, one of which is it’s openness to developer and debugging tools, and the fact that it runs a modified form of Linux as an operating system. If you’re like me and quite fond of jumping around from ROM to ROM on your Android devices, a quick and easy way to backup your program files (and even settings) is quite desirable. Here’s my solution, hopefully it will help you. I know there are easier ways, but for a diehard geek who has the setup ready, this is the fastest way.

First step: Install Android Debug Bridge (adb)

adb is a tool found in the Android SDK, which you can download here. Once you unzip the SDK, add the directory to your path so you can call adb.exe from the command line (or just always run it from it’s tools directory). Once the SDK is installed, you can connect your device to your computer and make sure you SKIP the driver detection Windows automatically starts. If you don’t, Windows will install a generic USB device driver and adb won’t work. If you accidentally do this, follow the steps outlined here to fix the problem. You may want to use pstools to run Registry Editor as System to fully delete out the entries that the fix tells you to delete, otherwise it’s a long process of taking ownership of directories, giving yourself permission, and finally deleting the directory. Repeat 15 times. Sounds like fun right?

So how do you know you have adb installed and working? Well if you plug in your device and run the following command:

adb devices

and you get back something that looks like this:

List of devices attached

HT845GZ67642 device

then it’s working. If you get a message saying that no devices were found, then it isn’t!

Second step: Backup the applications (and settings)

Now that you have adb working, open a command line and make a new directory. To backup the apk files (The package files that store the program’s executables and libraries), run the following command:

adb pull /data/app ./

and you should see a long list of apk files being downloaded to your computer. UPDATE: if you’re using a ROM that places your applications on the SD card for speed and backup purposes, the above command won’t work. Instead use the following command:

adb pull /system/sd/app ./

Settings are a slightly different beast. They’re stored under /data/data on the device, and you may have to hunt around a bit to find what you’re looking for. running the following command will let you access your phone in the same way you’d SSH into a unix/linux machine, or work at the Mac command prompt:

adb shell

Some examples are below of often-backed-up files you may want to grab off your device:

MMS/SMS data: /data/data/com.android.providers.telephony/databases/mmssms.db

Browser settings: /data/data/com.android/browser

System WiFi Settings: /data/misc/wifi

Once you have everything you want backed up, it’s time to restore!

Third step: Restoring data

Assuming you want to restore APK files, and you have all of those in 1 directory, you can run the following command on a mac to install all those apk files:

find ./ –exec adb install {} \;

If you’re on a Windows machine, your command is a bit longer, and this assuems your apk files are in c:\backupapps

for %%f in (“C:\BackupApps\*.apk”) do adb install “%%f”

Alternatively, from a command line window in the directory you have your backed up apps, you can run the following on a Windows machine:

adb install *.apk

After the applications, you can restore whatever data files and settings you backed up. Oh, and for you apps2SD users that may have a really bloated extended partition and want to wipe clean, try the following to clear the EXT partition on your SD card so you can move new apps over (useful for those who are doing completely clean installs on SD cards that were previously used with apps2SD). You should do this from the Recovery image, not the actual live running version (e.g. reboot and hold Home to get to recovery image.)

mount /system/sd
rm -rf /system/sd/*

Hopefully this little walk-through was somewhat helpful for you! If so, leave a comment!

About Jon Westfall


Jon Westfall is the owner of JonWestfall.Com, a professor, author, technologist, and researcher! You can always find him at his blog. He also likes to share interesting and funny material at Shared By Jon.Did you find this page useful? Say Thanks!

19 thoughts on “Backup & Restore Android Apps Using ADB”

  1. Hey! Big thanks for the info.

    It’d be great if you added how to backup up your call log, I’ve looked a bit and I think it’s the telephony.db into the providers directory.

    Thanks again!

  2. Hi Jon,

    My text messaging app did a force close on me the other day and I lost ALL my text messages. I REALLY, REALLY need to get them back, and I’m guessing they are still there somewhere, hidden in the file system. Would you happen to have any idea how to restore this data or could you point me in the right direction? I don’t know much about Linux, but I can follow simple instructions…

    Thanks!
    Kyle

  3. Nobody needs to fiddle with adb anymore, to do app backups or the like.

    The same power (and then some) can be harnessed by using Titanium Backup from the Market :-)

  4. John, thanks for the great tips. However, I can’t get the commands to work – do these commands only work on a rooted phone? Will I lose my messages etc in the process of rooting?

  5. great stuff. just needed that. now i think we can make a windows/mac/linux script which can automatically download all apps and settings and save them in a seperate folder in PC. this would be a good backup. Keeping andoird backup on SDCARD is not so useful.
    Thanks again.

  6. Pingback: nerds hosting
  7. Pingback: INSTANT PC FOLDER

Leave a Reply