2

While there are tons of posts about ADB, I think we can all agree it is an elusive beast. Therefore asking if anyone can shed some light on the following:

The objective is to backup data from an app on device #1, change some database data in the app's database file stored in root/data/data/com.AppName.../apps/db, repackage the changes into an .ab and restore it to device #2 which will have the same App installed.

I have managed to create a .ab via adb backup (without .apk), have manipulated the db data after unpacking it from the .ab and have packed everything back into a .ab ready for restore to a new target device.

However, the restore does not yield any change on the new target device where the app has been pre-installed. This post seems to suggest that the app has to be installed via adb in order to get the data loaded.... but I'm not sure I'm understanding that.

I do have a copy of the .apk for the app which I could point to the mentioned restore script, but just not sure if that's the thing to do.

One more note is that I am working with unrooted devices. While I can see how adb backup could easily have read permission to app data, I never understood whether adb restore has permission by default to write app data to its destination under /root/data/data.

Sorry for the long post but just trying to be clear.

Thanks for any thoughts!

10
  • Are the source and the target device using the same Android version? It seems like Google has deactivated adb backup and restore on Android 12 if the app's targetSdkVersion exceeds a certain value. Not sure about Android 11.
    – Robert
    Jun 10 at 23:15
  • Hi, I tried to clarify the title because the original revision was unclear about the real issue. If it doesn't seem to be what you're asking, consider editing and clarifying it more. Thanks!
    – Andrew T.
    Jun 11 at 0:16
  • @Robert Target device is running Android 10.
    – mmediaman
    Jun 11 at 2:45
  • Just to clarify a little further, I found it wasn't necessary to take the data from device #1. I actually only needed to take a backup from device #2, modify the database data mentioned and now wanting to restore the data back to device #2. Therefore disregard any mention of device #1. The problem is simply not being able to get the repackaged .ab to restore to device #2 running Android 10. Also, only had luck using ADB 1.0.31 to perform the backup. Tried several other versions including current from platform-tools.
    – mmediaman
    Jun 11 at 2:53
  • Instead of using adb restore I would copy the .ab file to the phone and use the command bu inside adb shell. adb backup is just a wrapper for this bu binary, but executing it directly on the phone has the advantage that you see all potential error and warning messages. In parallel I recommend to have an adb logcat running to see if there are error message in logcat why the restore does not work.
    – Robert
    Jun 11 at 12:18

0

You must log in to answer this question.

Browse other questions tagged .