7

I have non-rooted Android 7.0 device (NVIDIA Shield Tablet) which was previously backed up with

adb backup -apk -shared -all -nosystem -f mybackup.ab

But restoring it with

adb restore mybackup.ab

results in that /Android/data, etc are restored, but the applications are not installed from apk files, no errors.

I've had to extract apk files from mybackup.ab and install them manually in batch with adb install <...>.apk. After that everything was fine.

I'm quite sure that I've previously had similar problem with 6.0. and Helium/Carbon before but thought that it was specific to backup method I've chosen.

What is the problem with adb restore? Is it because the device is non-rooted? Why does adb install work as expected then?

  • Did you ever find a solution? This is one of the top search results for this problem. – Skylar Ittner Jun 16 '17 at 4:26
  • @SkylarMT Not yet. Still have to use adb install in batch. Hope somebody can help on this. – Estus Flask Jun 16 '17 at 16:34
  • I had partial success using Titanium Backup to restore the adb backup file. It requires root and didn't get everything, but it restored over half the apps I had installed. – Skylar Ittner Jun 16 '17 at 21:01
  • See if this solution helps – beeshyams Jun 17 '17 at 5:40
2

Command adb restore are not install .apk back. Actually, this command is only write back system and data files. -Android dev site

If you want automate apps installation process:

  1. Add all extracted .apk to one folder
  2. Type for %f in (C:\_apk folder location_\*.apk) do adb install "%f" NOTE: If you have .apk files which have "spaces" in their names adb has not recognize spaces rewrite it with _ or whatever else.
  • Can you please specify the reference for this information if it's correct? Since adb backup backs up everything including apks, I would expect that adb restore does the opposite thing. Because otherwise it appears that apks just waste space in .ab file. – Estus Flask Jun 20 '17 at 14:53
  • In table 1.> Backup and Restore Commands on android dev site is adb restore command describe as "Restore the device contents from file" it is interpret for me as uncompress files and put in device only, not installation packages. it make sense, i think, for installation was define command adb install (its not necessarily have install funkcionality in other commands) but i agree it would be nice :) – MaTT Belis Jun 21 '17 at 7:14
  • @MaTTBelis "Restore contents from file" to me means restore everything the file holds (which includes installing the APK if it's there). And until MM it did exactly that (I'm using this since Android 4, when it was introduced). Problems started only with Android 7, where a bug seems to prevent installing the APK. On some devices, you find in logcat that it tries exactly that (but fails without saying so). Actually, for those devices Nils' answer works. – Izzy Oct 4 '18 at 11:44
2

I solved it with the following script

#!/bin/bash
killall adb > /dev/null 2>&1
set -e

if [ $# -ne 1 ]; then
  echo "Usage: $0 <package-name-without-ab>"
  exit 1
fi

export PATH=/opt/jdk1.8.0_152_jce/jre/bin:$PATH
ab=$1.ab
java -jar /opt/android-backup-extractor-20160710-bin/abe.jar unpack $ab $ab.tar apw; tar -xf $ab.tar --wildcards '*.apk' --strip-components=3
mv base.apk $ab.apk
rm $ab.tar
adb install $ab.apk

adb restore $ab

echo "Ready"

You need furthermore the android-backup-extractor. How ever in my experience adb backup is still not really safe. First of all some apps can set a flag, so they won't be backup. And the restore works only sometimes and not sure, for example if you change the device. It's a shame that in 2018 only Titanium Backup make good job, if you have a rooted phone.

  • I'd upvote this twice if I could! 3 days trying to get it working – this did the trick. Nominate you for "hero of the week" :) // Reference: BQ Aquaris X5 Plus on Nougat / LOS 14.1. – Izzy Oct 1 '18 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.