Android ROM Backup (root required)
Backup Android ROM / partitions with ADB.
- Install ADB / Fastboot for your OS
- Enable USB debugging in the developer options
-
- Go to "Settings" --> "About this device" --> Tab "Build-Number" 5 times
-
- Go to System --> Developer Options --> activate USB-Debugging & Root-Debugging
- Connect USB cable to your computer --> select "File Transfer" on your device and allow USB Debugging
- Open a shell (Terminal on Linux/Mac, PowerShell on Windows)
1$ adb shell
2$ su
Accept root access for ABD on Device
- Navigate to
/dev/block/platform
1$ cd //dev/block/platform
- List files in this directory
1$ ls --la
In this directory you will find folders with different names, it changes from device to device and OS version.
In my case I have 2 folders, one is "bootdevice", the other is "externdevice". The folder that we need is "bootdevice".
On other devices this folder is named "msm_sdcc.1" or "7824900.sdhci".
- Another methode to find the partitons on the EMMC is to use the "parted" utility. (not installed on my device). Later more
Here you can see the output from my device
1
2:/dev/block/platform # ls -la
3total 0
4drwxr-xr-x 4 root root 80 2023-08-14 21:34 .
5drwxr-xr-x 5 root root 1700 2023-08-14 21:34 ..
6drwxr-xr-x 3 root root 940 2023-08-14 21:34 bootdevice
7drwxr-xr-x 2 root root 80 2023-08-14 21:34 externdevice
Look at these folders, one of them has a folder named "by-name"
1cd bootdevice
2ls -la
If you in the right folder it should look somthing like this:
1:/dev/block/platform/bootdevice # ls -la
2total 0
3drwxr-xr-x 3 root root 940 2023-08-14 21:34 .
4drwxr-xr-x 4 root root 80 2023-08-14 21:34 ..
5drwxr-xr-x 2 root root 880 2023-08-14 21:34 by-name
6lrwxrwxrwx 1 root root 18 2023-08-14 21:34 mmcblk0 -> /dev/block/mmcblk0
7lrwxrwxrwx 1 root root 23 2023-08-14 21:34 mmcblk0boot0 -> /dev/block/mmcblk0boot0
8lrwxrwxrwx 1 root root 23 2023-08-14 21:34 mmcblk0boot1 -> /dev/block/mmcblk0boot1
9lrwxrwxrwx 1 root root 20 2023-08-14 21:34 mmcblk0p1 -> /dev/block/mmcblk0p1
10... # I have short the List
11lrwxrwxrwx 1 root root 20 2023-08-14 21:34 mmcblk0p9 -> /dev/block/mmcblk0p9
12lrwxrwxrwx 1 root root 22 2023-08-14 21:34 mmcblk0rpmb -> /dev/block/mmcblk0rpmb
- Go to the folder "by-name" and list the directory
1cd by-name
2ls -la
The output looks like this:
1:/dev/block/platform/bootdevice/by-name # ls -la
2total 0
3drwxr-xr-x 2 root root 880 2023-08-14 21:34 .
4drwxr-xr-x 3 root root 940 2023-08-14 21:34 ..
5lrwxrwxrwx 1 root root 21 2023-08-14 21:34 boot -> /dev/block/mmcblk0p28
6lrwxrwxrwx 1 root root 20 2023-08-14 21:34 boot_para -> /dev/block/mmcblk0p1
7lrwxrwxrwx 1 root root 21 2023-08-14 21:34 cache -> /dev/block/mmcblk0p32
8lrwxrwxrwx 1 root root 21 2023-08-14 21:34 dtbo -> /dev/block/mmcblk0p29
9lrwxrwxrwx 1 root root 20 2023-08-14 21:34 expdb -> /dev/block/mmcblk0p4
10lrwxrwxrwx 1 root root 21 2023-08-14 21:34 flashinfo -> /dev/block/mmcblk0p40
11lrwxrwxrwx 1 root root 20 2023-08-14 21:34 frp -> /dev/block/mmcblk0p5
12lrwxrwxrwx 1 root root 21 2023-08-14 21:34 gz1 -> /dev/block/mmcblk0p23
13lrwxrwxrwx 1 root root 21 2023-08-14 21:34 gz2 -> /dev/block/mmcblk0p24
14lrwxrwxrwx 1 root root 21 2023-08-14 21:34 lenovocust -> /dev/block/mmcblk0p33
15lrwxrwxrwx 1 root root 21 2023-08-14 21:34 lenovoraw -> /dev/block/mmcblk0p34
16lrwxrwxrwx 1 root root 21 2023-08-14 21:34 lk -> /dev/block/mmcblk0p26
17lrwxrwxrwx 1 root root 21 2023-08-14 21:34 lk2 -> /dev/block/mmcblk0p27
18lrwxrwxrwx 1 root root 21 2023-08-14 21:34 logo -> /dev/block/mmcblk0p14
19lrwxrwxrwx 1 root root 21 2023-08-14 21:34 md1img -> /dev/block/mmcblk0p17
20lrwxrwxrwx 1 root root 20 2023-08-14 21:34 metadata -> /dev/block/mmcblk0p8
21lrwxrwxrwx 1 root root 20 2023-08-14 21:34 nvcfg -> /dev/block/mmcblk0p6
22lrwxrwxrwx 1 root root 20 2023-08-14 21:34 nvdata -> /dev/block/mmcblk0p7
23lrwxrwxrwx 1 root root 21 2023-08-14 21:34 nvram -> /dev/block/mmcblk0p25
24lrwxrwxrwx 1 root root 21 2023-08-14 21:34 otp -> /dev/block/mmcblk0p39
25lrwxrwxrwx 1 root root 20 2023-08-14 21:34 para -> /dev/block/mmcblk0p3
26lrwxrwxrwx 1 root root 21 2023-08-14 21:34 persist -> /dev/block/mmcblk0p15
27lrwxrwxrwx 1 root root 23 2023-08-14 21:34 preloader_a -> /dev/block/mmcblk0boot0
28lrwxrwxrwx 1 root root 23 2023-08-14 21:34 preloader_b -> /dev/block/mmcblk0boot1
29lrwxrwxrwx 1 root root 21 2023-08-14 21:34 product -> /dev/block/mmcblk0p35
30lrwxrwxrwx 1 root root 21 2023-08-14 21:34 proinfo -> /dev/block/mmcblk0p12
31lrwxrwxrwx 1 root root 20 2023-08-14 21:34 protect1 -> /dev/block/mmcblk0p9
32lrwxrwxrwx 1 root root 21 2023-08-14 21:34 protect2 -> /dev/block/mmcblk0p10
33lrwxrwxrwx 1 root root 20 2023-08-14 21:34 recovery -> /dev/block/mmcblk0p2
34lrwxrwxrwx 1 root root 21 2023-08-14 21:34 scp1 -> /dev/block/mmcblk0p19
35lrwxrwxrwx 1 root root 21 2023-08-14 21:34 scp2 -> /dev/block/mmcblk0p20
36lrwxrwxrwx 1 root root 21 2023-08-14 21:34 sec1 -> /dev/block/mmcblk0p16
37lrwxrwxrwx 1 root root 21 2023-08-14 21:34 seccfg -> /dev/block/mmcblk0p11
38lrwxrwxrwx 1 root root 21 2023-08-14 21:34 spmfw -> /dev/block/mmcblk0p18
39lrwxrwxrwx 1 root root 21 2023-08-14 21:34 sspm_1 -> /dev/block/mmcblk0p21
40lrwxrwxrwx 1 root root 21 2023-08-14 21:34 sspm_2 -> /dev/block/mmcblk0p22
41lrwxrwxrwx 1 root root 21 2023-08-14 21:34 system -> /dev/block/mmcblk0p37
42lrwxrwxrwx 1 root root 21 2023-08-14 21:34 tee1 -> /dev/block/mmcblk0p30
43lrwxrwxrwx 1 root root 21 2023-08-14 21:34 tee2 -> /dev/block/mmcblk0p31
44lrwxrwxrwx 1 root root 21 2023-08-14 21:34 userdata -> /dev/block/mmcblk0p38
45lrwxrwxrwx 1 root root 21 2023-08-14 21:34 vbmeta -> /dev/block/mmcblk0p13
46lrwxrwxrwx 1 root root 21 2023-08-14 21:34 vendor -> /dev/block/mmcblk0p36
- Now you can copy the partitions with "dd" to your external SD Card.
If you don't have an SD-Card slot you can copy most of the partition on your internal storage. You can't copy the "userdata" partition because this is the partition where you write the dump of the partition.
So I recommend you to use an external SD Card.
Open a new terminal window and use the commands at point 6 to open a second ADB root sesion.
Alternative you can coppy the output from point 9.
- Navigate to your external SD-Card, in my case it's in
/storage/81EE-1D09
, the last folder changes from device and SD-Card. You can usels -la
and look for files on the SD-Card.
1cd /storage
2ls -la
The output looks like this:
1:/storage # ls -la
2total 44
3drwx--x--- 5 shell everybody 120 2023-08-14 21:35 .
4drwxr-xr-x 31 root root 4096 2023-07-16 09:27 ..
5drwxrwx--- 22 root everybody 32768 2023-08-18 12:30 81EE-1D09
6drwx--x--x 4 root everybody 4096 2023-08-13 19:16 emulated
7lrwxrwxrwx 1 root root 7 2023-08-14 21:34 sdcard0 -> /sdcard
8drwxr-xr-x 2 root root 60 2023-08-14 21:35 self
You see the SD-Card, witch is 81EE-1D09
, is owned by "root" but accessible for everybody. So this is a good hint for the right device.
1cd 81EE-1D09
2ls -la
Output looks somthing like this, depending on the files on your SD-Card.
1:/storage/81EE-1D09 # ls -la
2total 48896
3drwxrwx--- 2 root everybody 32768 2022-07-05 21:36 Alarms
4drwxrwx--- 5 root everybody 32768 2022-11-10 09:19 Android
5drwxrwx--- 2 root everybody 32768 2023-08-13 19:16 Audiobooks
6drwxrwx--- 3 root everybody 32768 2022-10-31 08:53 DCIM
7drwxrwx--- 2 root everybody 32768 2023-08-13 19:16 Documents
8drwxrwx--- 2 root everybody 32768 2022-10-25 16:18 Download
9drwxrwx--- 2 root everybody 32768 2022-09-01 21:28 ISO
10drwxrwx--- 2 root everybody 32768 2022-07-05 21:35 LOST.DIR
11drwxrwx--- 3 root everybody 32768 2023-08-13 19:16 Movies
12drwxrwx--- 7 root everybody 32768 2023-08-13 19:16 Music
13drwxrwx--- 2 root everybody 32768 2022-07-05 21:36 Notifications
14drwxrwx--- 3 root everybody 32768 2023-08-13 19:16 Pictures
15drwxrwx--- 2 root everybody 32768 2022-07-05 21:36 Podcasts
16drwxrwx--- 2 root everybody 32768 2023-08-13 19:16 Recordings
17drwxrwx--- 2 root everybody 32768 2022-07-05 21:36 Ringtones
18drwxrwx--- 3 root everybody 32768 2022-10-03 09:46 TWRP
19drwxrwx--- 2 root everybody 32768 2023-01-28 16:09 apk
20drwxrwx--- 2 root everybody 32768 2022-11-22 08:38 keepass
21-rwxrwx--- 1 root everybody 129627 2022-10-03 13:15 orange_state_disabler_MTK\ Only.zip
22drwxrwx--- 2 root everybody 32768 2023-08-13 16:21 rom
- [Optional] Create a new folder and go to it to stay organised. In my case it's named "backup"
1mkdir backup
2cd backup
- Create the copy / dump from the partition using "dd"
dd if=/dev/block/mmcblk_partition_you_want_dumped of=partition_name.img bs=4096
So in my case, I want to backup the recovery partition so the command looks like this:
1dd if=/dev/block/mmcblk0p2 of=recovery.img bs=4096 <
28192+0 records in
38192+0 records out
433554432 bytes (32 M) copied, 1.291746 s, 25 M/s
Done
Now you have a copy of your partiton's that you want.
You can write this dump back to your device with Fastboot or a custom recovery like TWRP.
- Alex