Backup and restore your Android phone using adb

Using the Android Debug Bridge utility (adb) to backup your Android phone

March 6, 2017 - 4 minute read -
android windows linux

Backup

Backing up your Android phone by using the phone manufacturer’s prescribed software is in most cases a chore, there is a more easy way to backup your phone’s data and apps using adb. Android Debug Bridge or adb as it’s commonly known is one of the command line tools that is part of the Android SDK package, this tool lets you communicate with your Android phone and can perform a variety of actions such as installing and debugging apps as well as helping to backup your phone’s data and apps safely and securely on your computer no matter which OS your computer runs on be it on MacOS, Windows, or Linux.

To get started on backing up your Android phone’s data and apps using adb, you need to have the tool installed already, if not, lifehacker has a guide on how you can easily install Android tools like adb on your OS of choice.

Once the adb tool is up and running on your computer, the next step is to enable developer options on your Android phone. Follow the steps below to do that (the screenshots below are from a phone running the latest Android software release (Nougat 7.1.1):

Step 1: Launch the settings app from the app drawer or notification shade

Step 2: Scroll to the bottom and tap on ‘About phone’. about phone screen

Step 3: Scroll down in this menu and there should be an option labelled ‘Build number’ build number

Step 4: Tap repeatedly on this option until you see a prompt on the phone’s screen showing the text ‘You have enabled development settings’ development settings

Step 5: Now go back to the main settings screen and scroll to the bottom, there should now be a new option labelled ‘Developer options’ developer options

Step 6: Now to enable adb debugging on your phone, tap on the ‘Developer options’ label and turn it on by tapping on the button near the top as shown below developer options turn on

Step 7: You should now get a prompt asking if you want to ‘Allow development settings?’, tap ‘OK’ to enable adb usb debugging. For some newer devices with the latest Android OS software installed, you might need to scroll to down the menu a bit until you see an option labelled ‘Android debugging’, click on this label to enable Android debugging on your phone enable android debugging

Now that you have enable adb debugging on your device, the next step is to connect your Android phone to your PC which should already have adb installed (you might get a prompt on your phone once you connect it to your PC asking if you want to allow USB debugging, enable the option to ‘Always allow from this computer and then tap OK) and then open your terminal(Linux) or command prompt (Windows). allow usb debugging

To make sure your phone is detected by your PC via adb, in the terminal or command prompt, type the following command:

adb devices

and press enter, if everything is working as it it should, you should get a similar response as shown below: adb devices

Now to backup your device (apps + data) using adb, still on your terminal or command prompt, enter the following:

adb backup -apk -shared -all -f backup-file.adb
  • apk – Backs up your apps.
  • noapk – Does not backup apps.
  • shared – Backs up data on the SD card.
  • noshared – Does not backup data on the SD card.

adb backup

Your phone should now display a prompt asking you to enter a password if you want to encrypt the full backup of your phone, best to use a password to keep your data safe. Tap ‘BACK UP MY DATA’ and the backup up process will start. adb backup prompt

There will be a prompt on your phone showing ‘Backup starting’ start adb backup

The backup time depends on the amount of apps and data you have on your phone. Once the process is complete, a prompt will appear on your phone stating ‘backup finished’ and the backup file will be in the current working location which is usually the user’s home directory for Linux users and in C:\Users\your_user_name for Windows OS users.

backup completed

Restore

To restore your phone from the backup file you created earlier, use the adb restore command on the terminal or command prompt (note: change the working directory to the location of the adb backup file)

adb restore backup-file.adb

adb restore

Your phone will then prompt you for the password you used earlier to encrypt the backup file
adb restore prompt

Input the password and the tap on RESTORE MY DATA to start the restore process, nothing else to do now but wait until the backup process is completed