Created
January 27, 2025 00:02
-
-
Save nutrino/0542fa8d73c2f82953a378734b32b480 to your computer and use it in GitHub Desktop.
Revisions
-
nutrino created this gist
Jan 27, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ adb shell pm list packages -3 > wear-os-packages-out.txt mkdir ~/wear-os-backup #!/bin/zsh set -x BACKUP_DIR=~/wear-os-backup PACKAGE_LIST_FILE=~/wear-os-packages-out.txt ADB_PATH=~/Library/Android/sdk/platform-tools/adb # Create a backup directory mkdir -p "$BACKUP_DIR" # Backup APKs (including split APKs) while read -r line; do package="${line#package:}" # Remove "package:" prefix echo "Processing package: $package" # Get all APK paths for the package apk_paths=$($ADB_PATH shell pm path "$package" 2>/dev/null | sed 's/package://') echo "$apk_paths" # Check if APK paths exist if [ -z "$apk_paths" ]; then echo " Warning: No APKs found for $package. Skipping..." continue fi # Create a subdirectory for the package (to avoid filename collisions) package_dir="$BACKUP_DIR/$package" mkdir -p "$package_dir" # Pull all APKs for this package echo "$apk_paths" | while read -r apk_path; do echo " Pulling: $apk_path" $ADB_PATH pull "$apk_path" "$package_dir/" if [ $? -ne 0 ]; then echo " Error: Failed to pull $apk_path" fi done done < $PACKAGE_LIST_FILE