Skip to content

Instantly share code, notes, and snippets.

@testica
Last active December 11, 2018 10:05
Show Gist options
  • Save testica/179d7b826c21b2547dbfc8d81c2e3e63 to your computer and use it in GitHub Desktop.
Save testica/179d7b826c21b2547dbfc8d81c2e3e63 to your computer and use it in GitHub Desktop.
Shell script to extract backup files from android application via adb
#!/bin/bash
# Script to make and get android application backup (databases-extract purpose)
# Use: agentx_get_backup <package_name>
# Example: agentx_get_backup com.ltapps.textscanner
package_name=$1
echo ">>>>>> Please, accept backup creation (set password when device is encrypted) <<<<<<"
# Execute backup create command
adb backup -f /var/tmp/backup.ab -noapk $package_name
# Execute backup decompress command
dd if=/var/tmp/backup.ab bs=24 skip=1 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > /var/tmp/data.tar
# Decompress tar file
rm -r $1_backup || true
mkdir $1_backup
tar xvC $1_backup -f /var/tmp/data.tar 2> /dev/null
echo "Backup decompressed in ./$1_backup directory"
@testica
Copy link
Author

testica commented Dec 11, 2018

Make sure to have adb in your $PATH

echo "export PATH=$PATH:/Users/<your_user>/Library/Android/sdk/platform-tools/" >> ~/.bash_profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment