|
1 | | -# Android Backup and resume - a shell script |
| 1 | +# Android Backup |
2 | 2 |
|
3 | | -> Copy files and photos from android mobile to PC with option to resume if download breaks in between. |
| 3 | +Copy photos and files from your Android device to your PC via a web interface — with folder browsing, pause/resume transfers, file management, and Wi-Fi ADB support. |
4 | 4 |
|
5 | | -## Usage |
| 5 | +--- |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +### 1. Go (1.21 or later) |
| 10 | + |
| 11 | +Download and install from [go.dev/dl](https://go.dev/dl). Verify with: |
| 12 | + |
| 13 | +```powershell |
| 14 | +go version |
| 15 | +``` |
6 | 16 |
|
7 | | -### Install ADB (if not already installed): |
| 17 | +### 2. ADB (Android Debug Bridge) |
8 | 18 |
|
9 | | -- On Windows: Download the Android SDK Platform Tools and extract the ZIP file. |
10 | | -- On macOS and Linux: Use a package manager (brew install android-platform-tools for macOS) or download and extract the Platform Tools ZIP file from the Android developer site. |
11 | | -- https://developer.android.com/tools/releases/platform-tools |
| 19 | +Download **Android SDK Platform Tools** from [developer.android.com/tools/releases/platform-tools](https://developer.android.com/tools/releases/platform-tools), extract the ZIP, and add the folder to your `PATH`. |
12 | 20 |
|
13 | | -### Enable Developer Options on your Android device: |
| 21 | +Verify with: |
14 | 22 |
|
15 | | -- Go to Settings > About phone. |
16 | | -- Tap Build number multiple times until it says "You are now a developer!" |
17 | | -- Go back to Settings > System > Developer options and enable USB Debugging. |
| 23 | +```powershell |
| 24 | +adb version |
| 25 | +``` |
| 26 | + |
| 27 | +### 3. Enable USB Debugging on your Android device |
| 28 | + |
| 29 | +1. Go to **Settings → About phone** |
| 30 | +2. Tap **Build number** 7 times until you see *"You are now a developer!"* |
| 31 | +3. Go to **Settings → System → Developer options** |
| 32 | +4. Enable **USB Debugging** |
18 | 33 |
|
19 | | -### Connect the Device via USB: |
| 34 | +--- |
20 | 35 |
|
21 | | -- Use a USB cable to connect your device to the computer. |
| 36 | +## Build |
22 | 37 |
|
23 | | -### Authorize the Device: |
| 38 | +```powershell |
| 39 | +cd d:\projects\Software\AndroidBackup |
| 40 | +
|
| 41 | +# Download dependencies |
| 42 | +go mod tidy |
| 43 | +
|
| 44 | +# Build the binary |
| 45 | +go build -o androidbackup.exe . |
| 46 | +``` |
24 | 47 |
|
25 | | -- When you plug the device into the computer, your Android device may prompt you to Allow USB debugging. Tap Allow. |
| 48 | +--- |
26 | 49 |
|
| 50 | +## Run |
27 | 51 |
|
28 | | -Run the ADB Shell |
| 52 | +```powershell |
| 53 | +.\androidbackup.exe |
29 | 54 | ``` |
| 55 | + |
| 56 | +Open your browser at **[http://localhost:8765](http://localhost:8765)** |
| 57 | + |
| 58 | +To use a different port: |
| 59 | + |
| 60 | +```powershell |
| 61 | +$env:PORT = "9000"; .\androidbackup.exe |
| 62 | +``` |
| 63 | + |
| 64 | +--- |
| 65 | + |
| 66 | +## Connect your Android device |
| 67 | + |
| 68 | +### Option A — USB |
| 69 | + |
| 70 | +1. Connect the device with a USB cable. |
| 71 | +2. When prompted on the phone, tap **Allow USB debugging**. |
| 72 | +3. Verify the device is detected: |
| 73 | + |
| 74 | +```powershell |
30 | 75 | adb devices |
31 | 76 | ``` |
32 | | -Output: |
| 77 | + |
| 78 | +Expected output: |
| 79 | + |
33 | 80 | ``` |
34 | 81 | List of devices attached |
35 | 82 | RZXXXXXXXXX device |
36 | 83 | ``` |
| 84 | + |
| 85 | +### Option B — Wi-Fi |
| 86 | + |
| 87 | +1. First connect via USB and run: |
| 88 | + |
| 89 | +```powershell |
| 90 | +adb tcpip 5555 |
37 | 91 | ``` |
38 | | -adb shell |
39 | | -``` |
40 | | -This should open the interactive shell. |
41 | | -If all above stuff works, you are ready to start. |
42 | 92 |
|
43 | | -Run the shell script as follows: |
| 93 | +2. Find your phone's IP address under **Settings → About phone → Status → IP address**. |
| 94 | +3. Disconnect the USB cable. |
| 95 | +4. In the web UI, enter the IP in the **Connect** field (e.g. `192.168.1.42`) and click **Connect**. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Usage |
| 100 | + |
| 101 | +| Step | Action | |
| 102 | +|---|---| |
| 103 | +| 1 | Open [http://localhost:8765](http://localhost:8765) | |
| 104 | +| 2 | Your connected devices appear in the left panel — click one to select it | |
| 105 | +| 3 | Browse the Android filesystem and navigate to the folder you want | |
| 106 | +| 4 | Click **← Use** to fill in the source path, or type it manually | |
| 107 | +| 5 | Click **Browse** next to the destination field to pick a local folder | |
| 108 | +| 6 | Click **Start Transfer** | |
| 109 | +| 7 | Monitor progress in the transfer queue — pause, resume, or cancel at any time | |
| 110 | + |
| 111 | +### Resume an interrupted transfer |
| 112 | + |
| 113 | +If a transfer stops (app closed, cable unplugged, etc.), reopen the app and click **Resume** on the paused transfer. Files already downloaded at their full size are skipped automatically. |
| 114 | + |
| 115 | +### File management on device |
44 | 116 |
|
45 | | -- On windows open the git bash or MobaXterm (Windows paths might be different on both terminals) |
| 117 | +Hover over any file or folder in the Android browser to reveal **rename** and **delete** buttons. |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## Transfer state |
| 122 | + |
| 123 | +Transfer progress is saved to: |
46 | 124 |
|
47 | 125 | ``` |
48 | | -./backup.sh [-r remote_folder] [-l local_folder] |
49 | | -e.g. ./backup.sh sdcard/DCIM/Camera /f/Photo/A52 |
| 126 | +%TEMP%\androidbackup_state.json |
50 | 127 | ``` |
51 | | -> If download breaks, re-run the script with same parameters, script will resume from last download. |
| 128 | + |
| 129 | +This file is read on startup, so transfers survive app restarts and can always be resumed. |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +## API reference |
| 134 | + |
| 135 | +The server exposes a REST API if you want to automate or script operations. |
| 136 | + |
| 137 | +| Method | Path | Description | |
| 138 | +|---|---|---| |
| 139 | +| `GET` | `/api/devices` | List connected ADB devices | |
| 140 | +| `POST` | `/api/devices/connect` | Connect a Wi-Fi device `{"address":"192.168.1.x"}` | |
| 141 | +| `POST` | `/api/devices/disconnect` | Disconnect a Wi-Fi device | |
| 142 | +| `GET` | `/api/android/browse?serial=&path=` | List files/folders on device | |
| 143 | +| `POST` | `/api/android/delete` | Delete a file or folder on device | |
| 144 | +| `POST` | `/api/android/rename` | Rename or move a file on device | |
| 145 | +| `GET` | `/api/local/browse?path=` | Browse local filesystem | |
| 146 | +| `POST` | `/api/transfers` | Start a new transfer | |
| 147 | +| `GET` | `/api/transfers` | List all transfers | |
| 148 | +| `GET` | `/api/transfers/:id` | Get a specific transfer | |
| 149 | +| `POST` | `/api/transfers/:id/pause` | Pause a running transfer | |
| 150 | +| `POST` | `/api/transfers/:id/resume` | Resume a paused or failed transfer | |
| 151 | +| `POST` | `/api/transfers/:id/cancel` | Cancel a transfer | |
| 152 | +| `WS` | `/ws` | WebSocket stream for real-time progress events | |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Shell script (legacy) |
| 157 | + |
| 158 | +The original Bash script is still available as `backup.sh`. See [README-sh.md](README-sh.md) for usage instructions. |
0 commit comments