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?


3 Answers 3


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>

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


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.


this seems particularly odd, but in that expected google evil way. From my own incomplete but growing understanding of things- you can convert the restore file to a tar file by changing the first 24 bytes. So then the question is, would a simple tar extraction in a particular way (remounting something or other rw temporarily?) accomplish the same thing the adb restore is doing? Of course the source is theoretically all there. I was planning on trying things out eventually and seeing if they seem to work good enough to justify not caring enough to dig through that source. Yes, this is a pretty crappy answer, but it seems worthwhile as a placeholder until a little adb shell script with tar invokage or the like takes its place, which is what I presume the original questioner and I would like to see.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .