8

I was looking into how to do batch backups through individual adb backup/restore commands (to have separate .ab files per package/application/data/etc.) (I'm aware of the Helium (Carbon) desktop app as an option for this - would be interested in writing my own script for fun anyway).

The reason for wanting to create individual .ab files vs a large one is I want to be able to have partial backup/restore functionality for just individual packages, and not have to do, for example, 50 apps all at once.

The main obstacle at the moment is that every time a backup/restore occurs, user input has to be given when the prompt comes up - is there a way around this to be able to use adb backup/restore for multiple individual packages through something like a shell script?

Thanks!

2

You can try using adb shell input tap <x> <y> where x and y are the coordinates of where you would like to tap on the screen (can show coords in Developer Options). I was able to use this code to restore an individual backup:

#$1 is backup file

adb restore ${1} &
sleep 2
adb shell input touchscreen tap <x> <y>
wait

I found it useful to sleep for a couple seconds after the restore command, but it may not be necessary.

1

So, it would appear that there's no built in and (at least seemingly) intended way for us to do this.

Instead, this is possible through the adb shell sendevent command - this can emulate touch input from a computer with the adb tools (and any relevant drivers) installed, provided the phone has provided adb access to that specific machine.

Events can be recorded using adb shell getevent and replayed with adb shell sendevent. A user could then record the accepting button presses, and save a script that replays them. Of course, this introduces issues such as when there's a screen overlay (e.g. from red shift lighting apps) preventing pressing of the button, if something else appears (maybe a chat bubble, etc.), and any other number of obstructions, so it's a workaround at best.

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.