Skip to content

Instantly share code, notes, and snippets.

@chihchun
Created January 6, 2014 06:46
Show Gist options
  • Save chihchun/8279161 to your computer and use it in GitHub Desktop.
Save chihchun/8279161 to your computer and use it in GitHub Desktop.
script for dump information and backup disks of an android device.
#!/bin/sh
set -x
set -e
D=$(date +"%Y%m%d%H%M%S")
mkdir ${D} && cd ${D}
# reboot to get clean kmsg
adb reboot || true
adb wait-for-device
adb shell cat -f /proc/kmsg > kmsg.txt
adb shell getprop > prop.txt
# pm
adb shell pm list packages > pm-packages.txt
adb shell pm list features > pm-features.txt
adb shell pm list permissions > pm-permissions.txt
adb shell pm list users > pm-users.txt
adb shell pm list libraries > pm-libraries.txt
adb shell pm list permission-groups > pm-permission-groups.txt
# paritions
adb shell mount > mount.txt
adb shell 'ls -l /dev/block/*/by-name/*' > blocks.txt
blocks=$(adb shell 'echo /dev/block/*/by-name/*')
# backup partition images
for block in $blocks ; do
adb shell cat $block | gzip -9 > block-$(basename $block).gz
done
adb shell dumpsys > dumpsys.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment