Hovatek Forum MOBILE Android [Tutorial] How to backup & restore apk + data (app settings) using ADB
Try our Online TWRP Builder..its free!
Can't login? Please, reset your password.


[Tutorial] How to backup & restore apk + data (app settings) using ADB

[Tutorial] How to backup & restore apk + data (app settings) using ADB

X3non
X3non
X3non
Recognized Contributor
22,062
01-03-2019, 06:16 PM
#1



This guide will show how to backup & restore apk + data (app settings) from an android phone using ADB

Requirements


Steps on how to check if an app supports backup through adb


follow the steps below to check if an app supports backup through adb

See the video tutorial below or @ https://youtu.be/AEyIWHLL2Is

  1. To check if an app supports backup through adb, type the command below and press Enter
    • adb shell pm dump com.package.name | grep ALLOW_BACKUP

    [Image: how-to-check-if-an-app-supports-backup-through-adb.png]

  2. The output will be blank if the app doesn't support backup OR if it does then you'll see a line with "flags=..."


Steps to backup & restore apk + data from an android phone using ADB


Follow the steps below to backup & restore apk + data from an android phone using ADB

  1. Extract the contents of adb + grep and open the folder
  2. Connect the phone and launch ADB command window. To launch ADB, right click on any empty space within the folder then select 'open command prompt here' or 'open power shell here'

    [Image: how-to-check-the-UserID-or-UID-of-an-ins...-app-1.jpg]

  3. To backup a single apk file along with it's data, type the command below and press Enter then unlock your phone and confirm the backup operation
    • adb backup -f app.backup -apk com.package.name

  4. To backup two or more apk files along with their data, write the package names beside each other with a space in between then type the command below and press Enter then unlock your phone and confirm the backup operation
    • adb backup -f app.backup -apk com.package.name1 com.package.name2

  5. To backup only data without the apk file, you can include two or more apps by writing the package names beside each other with a space in between then type the command below and press Enter then unlock your phone and confirm the backup operation
    • adb backup -f app.backup com.package.name

  6. To backup all userdata apps i.e excluding system apps, type the command below and press Enter then unlock your phone and confirm the backup operation
    • adb backup -f app.backup -all -apk -nosystem

  7. To restore the backup, type the command below and press Enter then unlock your phone and confirm the restore operation
    • adb restore app.backup

  8. In all the commands provided above,
    Quote:app.backup is the name of the backup file that will be saved on your PC, you can change the name as you see fit.
    com.package.name is the package name of the app you wish to backup.
    -all will include all apps.
    -apk will include the apk file in the backup.
    -nosystem will exclude system apps, it can be changed to -system to include system app (not advisable to do so)


Important Notice
  • ADB Backup works only on android version 4.0 and above
  • If you made a full backup then note that you can't select a specific app or apps to restore. To achieve this, you must backup each app one after the other or altogether using the backup command for two or more apps
  • You should be able to restore backup to another android device running the same or a higher android version
  • If you made a data only (i.e excluding apk) backup, then the phone you're restoring to must have the app already installed


Video Transcript
Quote:In this video tutorial, i'm going to be showing how to backup and apk file and it's data from an android phone using ADB
So the first thing you need to know is that not all apps will support backup using ADB
Some developers actually disable the feature from their application
Especially if the application collects sensitive data
Applications such as facebook, whatsapp, they don't accept this
So before we begin you need to install ADB and fastboot on your PC, enable USB debugging on your phone then finally check for the package name of the app you wish to backup
All these have a tutorial at the forum, you can check it out
So first thing we need to do now is to connect the android phone to the PC
Ok, so we'll launch ADB. To launch ADB, hold shift key then right click on any empty space
Open powershell window or open command prompt (whichever one you see)
So this is my ADB window
now to backup an apk file, so i've drafted out the package name of some of the apps i have
So to backup an apk file + the data this is the code we'll use
Now we'll need to also include the package name of the app we're trying to backup
so i'm going to use Xplore this is the package name
So this is the command to backup an APK + the data
app.backup , this is the file name we want to use to store the backup file
Ok, press Enter
Now you'll get the confirmation to unlock your device and confirm the backup operation
So i'll click backup my data, you'll see it will write backup starting and once backup is finished, it will also indicate backup finished
So we can confirm our backup, this is the file app.backup
So here, lets try and let actually try and uninstall the app to confirm that this actually worked
Ok so when i opened it, it opened app manager
So i've uninstalled Xplore
Now let's try and restore the app back along with the data
So to restore, we'll type ADB restore and the file name for the backup which is app.backup then click Enter
You'll get the same prompt to confirm restore data
So once restore is finished, you'll get the prompt restore finished on your phone
you can now disconnect the phone
Now lets check if..ok, there it is. Xplore has been restored back
You can see it opened exactly where it was when i last opened it
So that means backup was successful
So, if you want to backup just the data only without the apk file, this is the command
You'll notice that this command is different from the last one because it has no -apk
This -apk includes the apk file. So i'm saving this as app.backups
Now click Enter
confirm the backup
so backup is finished
Now you can see the sizes
This one contains the apk file + data
this contains only the data
Now what if you want to backup two different applications
The command is still the same thing
you'll just place the package names one after the other
So it will look something like this
package name for the first one and package name for the second
So to confirm if an apk file will allow backup, this is the command we'll use, so let's check if link2sd will allow for backup
To do this, you must use ADB + grep
you can check for this at the forum
It's still under this thread here, adb + grep
So here, it shows us the command that flags ALLOW_BACKUP
So that means link2sd will allow for backup operations
Now lets check, what if an app doesn't have the ALLOW_BACKUP flag
what will happen, so i have mega app and whatsapp so let's check these
Ok so i'll use the same command but i'll change the package name for link2sd to that off whatsapp
You see, it didn't give us any information. That means whatsapp doesn't allow for backup
Lets try the same thing but this time around, for Mega app
Mega app doesn't also allow for backup
So what will happen if we try to backup this app + it's data
now lets try it
So, i'm trying to backup an app that doesn't allow for backup
let me copy the code out
Ok, i want to save this as megaapp.backup
Ok, so i'll paste the command. To paste on powershell, just right click
It says unlock to confirm backup operation
So it says backup finished but here we have megaapp.backup, it's only 1 KB, which means it was not able to backup the app
So that's it for how to backup apk files + their data
These are the commands mostly used
This command is used to backup all userdata apps excluding system apps
This post was last modified: 04-10-2019, 11:46 PM by X3non.
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
YtWhTl
live chat
whatsapp telegram instagram