Backup applications on Android phone with ADB

The strength of Android OS lies in enumerable number of apps present in Google Play Store as well as other standalone sources. We use many of them quite regularly be it for social networking, games, banking, reading and many more. While using these apps they generate their own internal data for smooth running which is called as app data. e.g. If you are playing games, various levels that have been completed get stored, in an eBook app the eBooks you download are saved and likewise. Now in unfortunate events like the phone screen gets broken or hardware failure or someone deliberately putting a pattern lock/password or the phone is stolen etc. it is highly likely that you will lose all the data as after repair the servicing personnel will reset the phone. In such situations it is quite handy if we have backup of app data that can be restored.

Normally if you want to do backup and restore from phone alone, you need to root it. There are plenty of apps available which can accomplish this task on a rooted android device. But for unrooted device ADB (Android Debug Bridge) is a great tool for backing up apps as well as app data. ADB is a command line tool and has vast uses. Let’s see how we can use it for backup and restore operations.

Firstly you will need to enable ADB in your phone’s Developer Options. Secondly you will need PC running Windows with ADB package installed. Moreover when we want to backup any app, you’ll have to specify the correct package name for that app. There is very handy app called ApkExtractor where you can see package name for every app installed on your phone. Now connect your phone to PC with USB cable and open ADB. Type in

adb devices

You should see serial number of your connected phone.

Now note down the package names of the apps you want to backup from Apkextractor app on phone.

1. To backup app data along with apk

Type in this command:

adb backup -f “D:\myfolder\myapp.ab” -apk <package name>

-f parameter specifies the file location, -apk specifies to backup apk (and not only app data)

Once you enter this command on PC you will be prompted to unlock phone screen. Unlock screen and select ‘Back Up Data’ and also enter password if you have set up any previously. This command will store the backup to myapp.ab file on your PC. To restore this back to your phone simply type in:

adb restore “D:\myfolder\myapp.ab”

This command will restore entire app back to your phone.

2. To backup only app data

To backup only data don’t pass -apk parameter. This will only backup the app data in myapp.ab file. Remember that before you restore this backup the app should already be installed on the phone (From play store or from apk file which you are supposed to have).

3. To backup multiple apps

If you need to backup more than one app put in all package names in <package name> parameter with single space between each name. Alternatively if you want to backup all apps on phone you can use:

adb backup -f “D:\myfolder\myapp.ab” -all -apk -nosystem

-nosystem parameter is used to exclude system apps from backup, as restoring system apps sometimes causes stability issues.

Illustrations:

1. Backup ‘Candy Crush Saga’ game

The package name for Candy Crush Saga is com.king.candycrushsaga as seen in Apkextractor app. To backup this app, command would be

adb backup -f “D:\myfolder\myapp.ab” -apk com.king.candycrushsaga

Now your game will be saved in myapp.ab file. When you restore this file with ‘adb restore’ function complete game will be restored back to phone with all the achievements and levels intact.

  1. Backup Candy Crush Saga and Facebook

Type in this command:

adb backup -f “D:\myfolder\myapp.ab” -apk com.king.candycrushsaga com.facebook.katana

This command will backup both Candy Crush Saga and Facebook apps in one myapp.ab file. You may add n number of apps in this manner simultaneously.

Some facts about ADB Backup function:

  1. ADB Backup works only on Android version 4.0 and above.
  2. You can restore backup to another Android device (of another manufacturer) only if it is running higher version of Android.
  3. There is no provision of conditional restore i.e. you can’t choose specific items from backup file.
  4. ADB Backup is still little buggy and it is advisable to also explore other options (like rooting phone).

ADB: A Perfect companion for Android users

Android Debug Bridge (abbreviated as ADB) is a very powerful, though often neglected, tool to perform different tasks on an Android smartphone. As the name itself suggests ADB is a connection between your phone and a PC running Windows/Linux. It is basically a command line interface to accomplish various common as well as uncommon Android operations. Most basic tasks like transferring data files between PC & smartphone, installing an application from PC directly are possible through ADB. But its capabilities are better realized in situations where other routine apps are not helpful enough. Included among these are taking a backup of system as well as user installed apps, along with app data, which can be further restored in case of system failure, cracking a forgotten screen lock pattern/PIN/password, backing up contacts from a smartphone with broken screen and many more.

How to activate ADB?

To activate ADB on your phone navigate to Settings → Developer Options and enable the USB Debugging option by ticking check box against it. Sounds quite straight? In recent phones running Android 4.2+ like Nexus, Moto G etc. Developer Options menu cannot be found under Settings as it is hidden by the manufacturer in order to safeguard the phone against accidental (or Intentional) misuse. In this case go to Settings → About Phone and tap the Build Number option repeatedly for 4-5 times. Developer Options will now be activated and the message depicting the same will be flashed on the screen.

Now the next part is to prepare your Computer for communicating via ADB. For this two things are needed

  1. ADB drivers for your phone model
  2. Program to run ADB

For many of the phone models drivers for ADB are installed automatically on PC when it is connected via USB cable, provided USB Debugging mode is enabled. If this is not the case or an error is displayed by Windows OS try to find drivers on support page of your phone model on manufacturer’s website to obtain the drivers.

After installing the drivers a program that can run adb commands must be installed on PC. These are included in Android SDK (Software Development Kit) which can be downloaded from Google. But this is a hefty large package and also needs some skill for proper installation. As we are interested only in adb part this time (and not app development as such) downloading whole SDK and configuring it will be a waste. There is a very handy program Minimal ADB and Fastboot developed by XDA Forum member shimp208. Download and install it on the computer and you are good to go.

Running adb commands

Now open ‘Minimal ADB and Fastboot’ from desktop. You will see a command prompt pointing to the directory where the program is installed. Connect your phone to the PC and make sure that ‘USB Debugging Connected’ line appears on its status bar. Now from this prompt you can run any adb command as per your need. To illustrate simplest of the things, type ‘adb devices’ and hit Enter. If everything is perfect your phone’s Serial No will be shown, which means that you have successfully configured ADB. For more uses of adb explore this blog.

Taking thorough backup of android phone

Smartphones are an indispensable part of our daily lives nowadays. We use them for social networking, banking, entertainment, news alerts and many more tasks. Obviously large amount of data is aggregated day by day which includes contacted, SMS, app data etc. All this data is quite precious to the user. Once you opt for rooting the phone and eventually tweaking it either by flashing Custom ROM or any other zip package there is a great possibility of losing data. In order to avoid this we must have a thorough backup that can recover the phone if something goes wrong. Such a backup is known as Nandroid backup.

There are plenty of apps available on Play Store to perform backup tasks, both paid and free. Though they can backup data in phone, they can’t boot it up if flashing fails and you find phone dead. This is where Nandroid backup comes to our rescue. If you have it with you, the phone can be completely recovered to the original state. Then how to do it? Well, you will need to flash a custom recovery to replace your phone’s stock recovery. Two popular recovery solutions are CWM (Clockwork Mod) and TWRP (Team Win Recovery Project). Of course, your phone must be rooted to use them.

To enter recovery mode firstly phone should be switched off. Then restart the phone with pressing together Vol Up+Home+Power buttons until manufacturer’s logo appears. What you will now see is Recovery that is preinstalled which has limited functions and cannot be used for Nandroid backup. After rooting the phone the stock recovery can be changed by either flashing it through PC or by using flashable zip packages developed specifically for the phone model in question. Again you have to be careful to select recovery image designed for concerned phone model only.

Root android phone to extract more juice from it

Have you ever heard of rooting your android smartphone? It’s something really to give a chance at. Rooting literally means clearing access to root of android’s file system. By default all phone manufacturers have to sell unrooted device in the market, which implies that the system contents cannot be edited by the user. But once the phone is rooted we can obtain SuperUser or Administrator permissions.

Core Android operating system in a smartphone is located at /system partition. The data of applications that a user installs is located at /data partition while the temporary files generated during operation of a phone are stored in /cache. In an unrooted device these partitions cannot be accessed for modifying contents. But once the device is rooted the access to these partitions is cleared and a user can try various performance tweaks and customization options. User can even change the operating system installed by device manufactures (known as Stock ROM) and install another one developed by android community around the world. As Android is based on a Open Source Linux OS, any tech geek can alter or modify it for free distribution. These modified Android systems are known as Custom ROM in Android world.

Once root access is cleared user has to be cautious since now the phone is more vulnerable to external influences. We may end up in messing up the OS instead of modifying it for our use. Thanks to the apps like SuperSU or KingUser which act like a broker between OS and apps. Using any of these apps user can control the root privileges and grant root access to the apps and processes he desires.

What do we gain from rooting?
1. Access & modify system contents to improve efficiency, more customization etc.
2. Install custom fonts (Fonts those are not pre-installed in android.)
3. Install scripts for RAM management, extending internal memory and many other things.
4. Take a full backup of apps’ data (eg. levels completed in a game) and restore the same in case of any accident.
What we may loose?
1. Phone’s warranty, if it’s in warranty period. But in many cases it can be regained by unrooting.
2. In some phone models bootloader needs to be unlocked, in which case warranty is lost permanently.