Skip to content

Instantly share code, notes, and snippets.

@beenhere4hours
Last active July 27, 2017 18:12
Show Gist options
  • Save beenhere4hours/9f41e69d019bbe8042e1 to your computer and use it in GitHub Desktop.
Save beenhere4hours/9f41e69d019bbe8042e1 to your computer and use it in GitHub Desktop.
SGP - shell script to make pulling all data from apps easier
#!/bin/bash
INSPI="com.safeguardproperties.inspi"
PD="com.safeguardproperties.photodirect"
function deletePreviousData () {
echo
if [ -f ~/Downloads/data.ab ]; then
echo removing previous data file
rm -r ~/Downloads/data.ab
fi
if [ -d ~/Downloads/apps ]; then
echo "removing previous unpacked archive $1"
rm -rf ~/Downloads/apps/$1
fi
echo
}
function pullAppData () {
echo pulling inspi application data from device
adb backup -f ~/Downloads/data.ab -noapk $1
if [ -f ~/Downloads/data.ab ]; then
echo application data file pulled successfully
else
echo pulling application data failed!!!
selectMenu
fi
}
function extractDataFile {
cd ~/Downloads
if [ -f ~/Downloads/data.ab ]; then
echo extracting application data
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
else
echo the application data file does not exist!
selectMenu
fi
}
function selectMenu {
echo
echo Select an application below to pull data for:
OPTIONS="INSPI VWM PD QUIT"
select opt in $OPTIONS; do
if [ "$opt" = "INSPI" ]; then
deletePreviousData $INSPI
pullAppData $INSPI
extractDataFile
selectMenu
elif [ "$opt" = "VWM" ]; then
deletePreviousData $VWM
pullAppData $VWM
extractDataFile
selectMenu
elif [ "$opt" = "PD" ]; then
deletePreviousData $PD
pullAppData $PD
extractDataFile
selectMenu
elif [ "$opt" = "QUIT" ]; then
echo exiting script
return
fi
done
}
selectMenu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment