1

I have done many reinstalls of my OS on my Android phone in the last few months for various reasons. Every time, the biggest hassle is manually searching, downloading and installing all the apps I had in my previous installation.

I use a degoogled custom rom, downloading apps from F-Droid and Aurora Store, so no Google solutions are acceptable.

What I want, is to have a way to keep on my computer a copy of all the apks of the installed apps of my phone, and have it automatically updated too, so that when the time comes to reformat my phone and install everything all over, I will be able to simply adb install all of the apks in no time, instead of doing it all manually and waiting for them to also be downloaded. Any suggestions for how I can make that happen with existing programs, preferably open source?

5
  • 1
    If you know abd you can simply create a full backup of all non-system apps: adb backup -f all -all -apk -nosystem. Then unpack using the created backup via Android backup Extractor (abe), get the APK files and delete the other file(s).
    – Robert
    Jan 18 at 16:40
  • 1
    as you mentioned custom rom, Migrate is the first choice for free backup solution. Titanium Backup has option for scheduled backup
    – alecxs
    Jan 18 at 17:57
  • @Robert This only backs up a few of the installed apps.
    – Noob Doob
    Jan 19 at 2:33
  • @alecxs This seems interesting. Is it open source by chance?
    – Noob Doob
    Jan 19 at 13:47
  • nope, but ask the author in telegram group
    – alecxs
    Jan 19 at 13:58
3

If it's just the APK files, you could use the getapk script provided in the tools/ directory of my little helper Adebar, calling it e.g. with getapk user to retrieve all user-installed apps. You won't be interested in system apps, but for completeness:

$ getapk


getapk
Extracting APK files from a connected device.
getapk lets you extract a single app's APK, or that of all user apps,
all system apps, or all apps altogether – depending on what parameter
you passed it.

Syntax: /mnt/av/src/git/adebar/tools/getapk <package_name> | user | system | all

This requires ADB being available on your computer. Should you not have that yet, you might wish to take a look at Is there a minimal installation of ADB? here at our site. You don't write what OS you are on; getapk is a Bash script (as Adebar is a Bash tool), so it works best on Linux, was reported working fine on MAcOS, and also in Cygwin.

To have that automated, you could create a cron job (Linux/Mac; no idea how that works on Windows but AFAIK there's something like a "Scheduler" you could probably use). APKs will be named <packageName>.apk (e.g. org.fdroid.fdroid.apk) once retrieved, so always retrieving them to the same directory (i.e. calling the script while inside that directory) should take care that you have always the latest versions in there and no more. Though it wouldn't delete APKs of apps you've uninstalled later ;)

11
  • Nice that you already have a complete script for that. I noticed that the script was last changed 2 years ago. Is your script already capable of saving split APKs (where each app consists of multiple APK files on the device)?
    – Robert
    Jan 19 at 8:30
  • Seems to work for most apps installed. But for many I get a failed to stat remote object error. Searching around I found it might be possible to overcome it with root, but I'd rather not root because Magisk was the cause for many of the last rom reinstalls. Do you have a solution for that? Tried on Linux Mint 20.
    – Noob Doob
    Jan 19 at 13:55
  • 1
    @Robert feel free to build on it. I happily accept pull requests with improvements. And no, I haven't tried it with split APKs – hints are welcome, too. I guess the failed to stat could be such cases. The current logic is rather a "simple approach" which definitely can be improved…
    – Izzy
    Jan 19 at 15:22
  • 1
    @NoobDoob I don't have Shazam, and the YT app is pulled fine from the test device having it. But I just fixed the mv: cannot stat 'base.apk' error. Will see if I can reproduce (and fix) the other one. Oh: you did call it with the user parameter, not all – you just want to backup user apps, not those the ROM ships with, right? The full error message reads: failed to stat remote object '{path}': Permission denied and in my test was only on some system apps. I'd yet need to find a split APK to test that. Edit: found one, indeed same error (just without the "permission denied").
    – Izzy
    Jan 19 at 15:40
  • 1
    OK, there you go – grab the update which now handles split-apks as well! They will be placed into a subdir using tha packageName and keeping the original names for the APKs, so should the dev decide to change their names or numbers, you might need to "clean up" manually yourself (e.g. deleting files older than X).
    – Izzy
    Jan 19 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.