Created
May 16, 2015 05:46
-
-
Save romulof/6af8a8919660f395f975 to your computer and use it in GitHub Desktop.
Simple shell script to download Android SQLite database to your computer using a few `adb` commands. Based on: https://stackoverflow.com/a/12914297/314055
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REQUIRED_ARGS=2 | |
PULL_DIR="./" | |
if [ $# -ne $REQUIRED_ARGS ] | |
then | |
echo "Usage: $0 [package_name] [db_name]" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d shell 'run-as $1 cp /data/data/$1/databases/$2 /data/data/$1/databases/$2-copy'" | |
if [ $? -ne 0 ] | |
then | |
echo "Error cloning database" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d shell 'run-as $1 chmod 666 /data/data/$1/databases/$2-copy'" | |
if [ $? -ne 0 ] | |
then | |
echo "Error changing clone permission" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d shell 'cp /data/data/$1/databases/$2-copy /sdcard/$2'" | |
if [ $? -ne 0 ] | |
then | |
echo "Error coping to /sdcard" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d shell 'run-as $1 rm /data/data/$1/databases/$2-copy'" | |
if [ $? -ne 0 ] | |
then | |
echo "Error removing clone" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d pull /sdcard/$2 $PULL_DIR" | |
if [ $? -ne 0 ] | |
then | |
echo "Error downloading" | |
echo "" | |
exit 1 | |
fi; | |
eval "adb -d shell 'rm /sdcard/$2'" | |
if [ $? -ne 0 ] | |
then | |
echo "Error removing /sdcard copy" | |
echo "" | |
exit 1 | |
fi; | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works on Nexus 5 running Lollipop 5.1