From Newsgroup: comp.mobile.android
Having been on 'puters since before the PC, the one thing ingrained in my backup/restore methodology is to save all installers at installation time.
I generally save all installers to a USB drive attached to the desktop.
But how do you it with Android installers when Google Play deletes them?
Especially when most of the time the device is on your LAN over Wi-Fi.
This script will copy the APK after install to your desktop over Wi-Fi.
I wrote it yesterday and only tested on my phone & on Windows.
But it should work on any platform, when ported to that platform.
The concept is what matters as this backs up & restores sans the net.
i. You back up the installer at the time you installed the app
(Yes Virginia, this works even if you never did a backup prior.)
ii. Then, you copy your homescreen to any phone you want
iii. And then you tap on the gray icons, one by one, to restore
It's so elegant that I think others should try it too. Here's how...
1. Install any desired set of apps on your Android phone by any method
(Google Play, F-droid, Aurora, Github, developer home pages, etc.)
2. Then run this script, which brings up Muntashirakon App Manager
<
https://github.com/MuntashirAkon/AppManager> (apk)
<
https://muntashir.dev/AppManager/en/> (doc)
3. In App Manager on the phone, select the app(s) and press "Save APK".
That will save the APK or APKs bundle to a known static folder:
/storage/emulated/0/AppManager/apks (either name.apks or name.apk)
Voila!
You've now fully backed up every APK that you ever installed on the phone!
Better still, if you save your homescreen to a backup file (about 5MB),
then you can install everything on another phone w/o needing the Internet.
A. You backup your home screen by pressing your launcher backup button.
B. You restore that homescreen on any other Android phone you want.
C. For every gray icon, you just tap it and it re-installs the app.
Voila!
You've now got a brilliantly efficient backup/restore strategy working!
:: copyapk.bat
:: Pulls APKs saved by Muntashirakon App Manager from phone to desktop
:: -------------------------------------------------------------------
:: v1p4 20260730 Added instructions for saving APK and split APKs files
:: v1p3 20260730 Added a clean quit instead of typing control+C
:: v1p2 20260730 Added choice of opening Muntashirakon App Manager
:: v1p1 20260730 Added choice of destination directory
:: v1p0 20260730 Original version (for use with Muntashirakon Save APK)
:: -------------------------------------------------------------------
@echo off
setlocal enabledelayedexpansion
REM ===== Ask user if they want to open Muntashirakon App Manager =====
echo.
echo Do you want to open Muntashirakon App Manager before listing APKs?
echo Once open, select apps and tap the "Save APK" option.
echo Either an APK or an APKs bundle will be saved to
echo /storage/emulated/0/AppManager/apks/{file.apk,file.apks}
set /p openAM="Open App Manager? (Y/N): "
if /i "%openAM%"=="Y" (
echo Launching App Manager...
REM Try clean launch first
adb shell am start io.github.muntashirakon.AppManager/.main.MainActivity >nul 2>&1
REM If that fails, use monkey silently
adb shell monkey -p io.github.muntashirakon.AppManager 1 >nul 2>&1
echo App Manager launched. Press ENTER when ready to continue.
pause
)
REM ===== Default destination folder [change to your location ] =====
set "DEST=H:\software\backup"
echo.
echo Default destination is:
echo %DEST%
echo.
set /p changeDest="Press ENTER to accept, or type a new destination: "
if not "%changeDest%"=="" (
set "DEST=%changeDest%"
)
echo.
echo Using destination:
echo %DEST%
echo.
REM Create destination folder if missing
if not exist "%DEST%" (
echo Creating folder: %DEST%
mkdir "%DEST%"
)
echo.
echo Listing APK/APKS files on device...
echo.
REM Get file list from device
REM Split APKs are saved as name.apks, otherwise it's name.apk
adb shell ls "/storage/emulated/0/AppManager/apks" > filelist.txt
set /a count=0
REM Display numbered list
for /f "delims=" %%A in (filelist.txt) do (
set /a count+=1
set "file!count!=%%A"
echo !count!: %%A
)
if %count%==0 (
echo No APKs found in /storage/emulated/0/AppManager/apks
del filelist.txt
exit /b
)
echo.
echo Enter numbers to pull (example: 1 3 5), type ALL, or type Q to quit:
set /p selection="Selection: "
if /i "%selection%"=="Q" (
echo Exiting...
del filelist.txt
endlocal
exit /b
)
echo.
if /i "%selection%"=="ALL" (
echo Pulling ALL files...
for /l %%i in (1,1,%count%) do (
echo Pulling !file%%i! ...
adb pull "/storage/emulated/0/AppManager/apks/!file%%i!" "%DEST%"
)
goto done
)
REM Pull selected numbers
for %%i in (%selection%) do (
if %%i LEQ %count% (
echo Pulling !file%%i! ...
adb pull "/storage/emulated/0/AppManager/apks/!file%%i!" "%DEST%"
) else (
echo Invalid selection: %%i
)
)
:done
echo.
echo Done.
del filelist.txt
endlocal
:: end of copyapk.bat
--
We should never need the Internet just to backup & restore our programs.
--- Synchronet 3.22a-Linux NewsLink 1.2