Advertisement
metalx1000

Android Backup and Restore apps

Nov 29th, 2021 (edited)
1,404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.55 KB | None | 0 0
  1. #tools
  2. sudo apt install adb fastboot fdroidcl
  3.  
  4. ######INSTALL APPS#####
  5. #attach old phone and get a list of installed apps
  6. --all apps
  7. adb shell pm list packages > app.lst
  8. ---just installed apps
  9. adb shell pm list packages -3 -f > app.lst
  10.  
  11. #attach new phone and install apps from frdoid
  12. cat app.lst|while read app;do fdroidcl install $app;done
  13.  
  14. ##or you can pull all installed packages
  15. for APP in $(adb shell pm list packages -3 -f)
  16. do
  17.   adb pull $( echo ${APP} | sed "s/^package://" | sed "s/base.apk=/base.apk /").apk
  18. done
  19.  
  20. ###pull apks from old device###
  21. for i in $(adb shell pm list packages -3 | awk -F':' '{print $2}'); do                                                                    
  22.   adb pull "$(adb shell pm path $i | awk -F':' '{print $2}')"
  23.   mv base.apk $i.apk &> /dev/null
  24. done
  25.  
  26. #######COPY APP DATA#######
  27. #attach old phone and backup app data
  28. for APP in $(adb shell pm list packages -3)
  29. do
  30.   APP=$( echo ${APP} | sed "s/^package://")
  31.   adb backup -apk -f ${APP}.backup ${APP}
  32. done
  33.  
  34. #install and grant all permissions
  35. for app in *.apk;
  36. do
  37.   echo $app
  38.   adb install -g "$app"
  39. done
  40.  
  41. #restore app data
  42. adb restore app.backup
  43.  
  44. #uninstall unwanted apps
  45. adb shell pm uninstall --user 0  $(adb shell pm list packages |cut -d\: -f2|fzf)
  46.  
  47.  
  48. ####TERMUX####
  49. #notes from https://wiki.termux.com/wiki/Backing_up_Termux
  50. #BACKUP
  51. tar -zcf /sdcard/termux-backup.tar.gz -C /data/data/com.termux/files ./home ./usr
  52.  
  53. #restore
  54. tar -zxf /sdcard/termux-backup.tar.gz -C /data/data/com.termux/files --recursive-unlink --preserve-permissions
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement