Android offers ADB, the Android Debug Bridge.
The phone needs to be connected to a computer,
USB debugging or Android debugging (wording differs between Android versions) needs to be enabled in the Developer options in the Settings
(just tap on the Build number in Settings - About phone a few times to make the Developer options visible),
then ADB can be used from the computer side either with the full blown Android SDK, or with just the adb
commandline command available as part of the SDK platform tools … https://developer.android.com/tools/releases/platform-tools.
At first use, you will need to confirm this access from this particular computer on the phone, at that point you can also allow the phone to remember this decision so that you don’t have to do this step every single time.
This will let you do a lot of commandline things already within the limited scope of what a user is allowed to do on the phone, among them is installing Apps.
Furthermore, in the Developer options /e/OS allows you to enable Rooted debugging (not every Android OS allows this).
With Rooted debugging enabled, you can use the adb root
command to run ADB commands as root. For example, this lets you access the whole phone storage, not only the limited part a normal user can access, which could of course be interesting for App data backup purposes, see e.g. Android Backup and Restore Tools, mentioned in this forum here … [HOWTO] Backup and Restore Data on Android Devices - #36 by petefoth
Here’s a commented list of adb
commands for a start … https://gist.github.com/Pulimet/5013acf2cd5b28e55036c82c91bd56d8
If you want to install Apps this way, you will need their APK files.
There are various Apps offering to extract APKs of Apps on a phone where they are installed. If you want to go this route, make sure the extractor App you use supports so-called Split APKs, as some extracted App APKs will only correctly re-install afterwards when extracted by an App which supports this.
SAI supports this, for example (even if unmaintained now, still worked the last time I used it) … https://f-droid.org/en/packages/com.aefyr.sai.fdroid/, but there should be others, too.