doc:appunti:android:apk_backup
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
doc:appunti:android:apk_backup [2019/08/02 16:33] – niccolo | doc:appunti:android:apk_backup [2019/10/18 18:26] (current) – removed niccolo | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Backup Android apk da riga di comando ====== | ||
- | Vedere questo post: **[[https:// | ||
- | |||
- | <code bash> | ||
- | #!/bin/sh | ||
- | # | ||
- | # Backup Android apk files to PC, using adb command line. | ||
- | # | ||
- | # Copyright (C) 2019 Niccolo Rigacci < | ||
- | # | ||
- | # This is free software: you can redistribute it and/or modify | ||
- | # it under the terms of the GNU General Public License as published by | ||
- | # the Free Software Foundation, either version 3 of the License, or | ||
- | # (at your option) any later version. | ||
- | |||
- | # Some packages are in paths requiring root privileges. | ||
- | paths_require_root='/ | ||
- | # To pull protected apk, need to copy in normal storage. | ||
- | tmp_path='/ | ||
- | |||
- | if [ -z " | ||
- | # Get the list of installed packages (was "pm list packages" | ||
- | # Each output line is: package:< | ||
- | adb shell cmd package list packages -f | rev | cut -f1 -d= | rev | ||
- | echo | ||
- | echo " | ||
- | echo | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | package=" | ||
- | if !(adb shell cmd package list packages | cut -f2 -d: | egrep -q " | ||
- | echo " | ||
- | exit 1 | ||
- | else | ||
- | # TODO: Shoul select only " | ||
- | # TODO: sub-optimal solution is to use head -n1 | ||
- | version=" | ||
- | # TODO: Problem if path contains spaces. | ||
- | package_paths=" | ||
- | for pm_path in $package_paths; | ||
- | echo " | ||
- | apk_name=" | ||
- | dst_filename=" | ||
- | su_required=' | ||
- | for p in $paths_require_root; | ||
- | if (echo " | ||
- | su_required=' | ||
- | fi | ||
- | done | ||
- | |||
- | if [ " | ||
- | echo " | ||
- | # Check if temporary diretcory exists. | ||
- | if ! adb shell cd " | ||
- | echo " | ||
- | exit 1 | ||
- | fi | ||
- | # Copy apk to temporary directory, using " | ||
- | if ! adb shell su --command "cp \" | ||
- | echo " | ||
- | exit 1 | ||
- | fi | ||
- | adb pull " | ||
- | RET=$? | ||
- | adb shell rm " | ||
- | else | ||
- | adb pull " | ||
- | RET=$? | ||
- | fi | ||
- | if [ $RET -ne 0 ]; then | ||
- | echo " | ||
- | else | ||
- | echo "INFO: Downloaded file \" | ||
- | fi | ||
- | done | ||
- | exit | ||
- | fi | ||
- | </ |