Skip to content

Instantly share code, notes, and snippets.

@do9iigane
Created December 22, 2016 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save do9iigane/79ef36cc8ec4b6b02585757a3ca7490c to your computer and use it in GitHub Desktop.
Save do9iigane/79ef36cc8ec4b6b02585757a3ca7490c to your computer and use it in GitHub Desktop.
adb backup all packages by shell
FILENAME="packages.txt"
adb shell pm list package > ./$FILENAME;
echo "packages list output to ./$FILENAME";
cat ./$FILENAME | sed -e 's/package://g' | while read LINE;do
APKNAME=`echo ${LINE} | tr -d '\r'`
if [ ! -e $APKNAME.ab ]; then
echo "backup start : ${APKNAME}";
adb backup -apk $APKNAME -shared -f $APKNAME.ab;
echo "backup complete : ${APKNAME} \n";
else
echo "$APKNAME.ab is already backup. skip this line.";
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment