📜 ⬆️ ⬇️

How to make nandroid backup device directly to your computer, bypassing the sdcard

Hello, Habrahabr.

It so happened that I needed to create a complete copy of the Android device, which completely lacked the tools commonly used for this. The search led me to the XDA forum, where this comprehensive instruction was found, which came in handy and which I decided to share with you.
The article has my comments, since I used this instruction to create a backup of the Teclast x98 3g tablet.

general information


This guide is intended to help create a full backup of your device (all memory with all partitions) or a single partition (including sdcards, etc.) directly to your computer:


')
This instruction is applicable when the device is turned on or in ClockworkMod Recovery (in these cases, the ADB will work, this instruction is not applicable in Fastboot mode). If in addition there will be no remarks, all commands are intended for use in Windows. The same goes for Linux with Unix.

Requirements




Partitions in the device


Now you need to identify the sections and blocks on your device, a copy of which you want to make. You can use tar or dd to copy a single partition, while you need to use only dd to copy the entire memory.

On Teclast x98 3g , two commands are used to define partitions: cat proc / partitions and mount.

An example of what should appear in your response to their input in the terminal.
127 | root @ android: / # mount
mount
rootfs / rootfs ro, relatime 0 0
tmpfs / dev tmpfs rw, nosuid, relatime, mode = 755 0 0
devpts / dev / pts devpts rw, relatime, mode = 600 0 0
proc / proc proc rw, relatime 0 0
sysfs / sys sysfs rw, relatime 0 0
none / acct cgroup rw, relatime, cpuacct 0 0
tmpfs / mnt / secure tmpfs rw, relatime, mode = 700 0 0
tmpfs / mnt / asec tmpfs rw, relatime, mode = 755, gid = 1000 0 0
tmpfs / mnt / obb tmpfs rw, relatime, mode = 755, gid = 1000 0 0
none / dev / cpuctl cgroup rw, relatime, cpu 0 0
[b] / dev / block / mmcblk0p9 / system ext4 ro, noatime, data = ordered 0 0
/ dev / block / mmcblk0p7 / cache ext4 rw, nosuid, nodev, noatime, data = ordered 0 0
/ dev / block / mmcblk0p6 / config ext4 rw, nosuid, nodev, noatime, data = ordered 0 0
/ dev / block / mmcblk0p10 / data ext4 rw, nosuid, nodev, noatime, noauto_da_alloc, data = ordered 0 0
/ dev / block / mmcblk0p8 / logs ext4 rw, nosuid, nodev, relatime, data = ordered 0 0 [/ b]
none / sys / kernel / debug debugfs rw, relatime 0 0
/ dev / fuse / mnt / shell / emulated fuse rw, nosuid, nodev, relatime, user_id = 1023, group_id = 1023, default_permissions, allow_other 0 0
none / proc / sys / fs / binfmt_misc binfmt_misc rw, relatime 0 0
tmpfs / mnt / libreg tmpfs rw, noexec, noatime, size = 4k, mode = 700, gid = 1003 0 0
/ dev / block / vold / 179: 1 / storage / sdcard_ext fuseblk rw, relatime, user_id = 0, group_id = 0, allow_other, blksize = 4096 0 0
root @ android: / # cat proc / partitions
cat proc / partitions
major minor #blocks name

179 10 30535680 mmcblk0
179 11 229376 mmcblk0p1
179 12 32768 mmcblk0p2
179 13 32768 mmcblk0p3
179 14 131072 mmcblk0p4
179 15 131072 mmcblk0p5
179 16 131072 mmcblk0p6
179 17 786432 mmcblk0p7
179 18 262144 mmcblk0p8
179 19 1048576 mmcblk0p9
259 0 27742188 mmcblk0p10
179 30 2048 mmcblk0boot1
179 20 2048 mmcblk0boot0
179 0 30657536 mmcblk1
179 1 30657504 mmcblk1p1


Usually on Android, the entire block containing all sections is located in / dev / block / mmcblk0, and all other sections are its subsections. You can install parted with GPT support to view information about all sections.

All phone memory is> / dev / block / mmcblk0 (although, on some phones, this may be a sdcard).
Sections -> it all depends on the specific device. Usually, / dev / block / platform / dw_mmc / by-name / lists all partitions for this device.

Backup All Memory (via adb)


Connect your phone with USB debugging enabled to your computer.

As for Teclast x98 3g and the case when the device does not boot (bootloop). It is very important that USB debugging be turned on before this happens. Turn off the tablet completely, disconnect all cables, allow a couple of seconds to “rest” and connect the cable from the computer to the tablet, such a large white battery should appear that will show that the charging process is in progress, only then, even in the off state, it will be possible to work with the device through the terminal and adb.

Start Cygwin Terminal and enter (if necessary, replace mmcblk0):
adb forward tcp: 5555 tcp: 5555
adb shell
su
/ system / xbin / busybox nc -l -p 5555 -e / system / xbin / busybox dd if = / dev / block / mmcblk0


You will see a flashing cursor on the next line to the left. At the moment, the device is waiting for the Block to be transmitted over the network.

Open another Cygwin Terminal and enter:
adb forward tcp: 5555 tcp: 5555
cd / path / to / store / the / backup
nc 127.0.0.1 5555 | pv -i 0.5> mmcblk0.raw


You will see how the file size begins to increase until the entire Block you have selected is completely copied. Now you have a full backup of the device in raw format. You can see all the contents in the copied Block using gptfdisk, available for Windows, Linux and other operating systems ( official site or SourceForge ). You can do the same with ClockworkMod Recovery, but initially you need to mount the Partition / system, because BusyBox, included in ClockworkMod, does not have netcat, so you need to use netcat from the / system partition of your device.

With the help of certain tools in Linux, you can modify and retrieve the necessary Partitions from the entire Block.

You can use ADB via WiFi, just like Wi-Fi ADB .

Backup all memory (via WiFi)


Link to the author: Nandroid directly to computer w / o sdcard .

It is necessary:


The good tone rule is to copy myfifo to / cache, and not to / data, since you can accidentally overwrite important data if you use raw data for recovery.

Launch Cygwin Terminal and enter:
adb shell
su
mkfifo / cache / myfifo
ftpput -v -u user -p pass -P 40 COMPUTER_IP block.raw / cache / myfifo


Open another Cygwin Terminal and enter:
adb shell
su
dd if = / dev / block / mmcblk0p12 of = / cache / myfifo


Some notes:


Backup of all memory (via USB-modem or Wi-Fi-modem)


To do this, you must disable all network connections on your computer, in addition, through which you will carry out the copying process.
Once you connect the computer to the Android device, you can view the IP of the computer and the IP of the device in the “Connection Properties”. IP - will be the IP of the computer itself, and Gateway will contain the IP of the Android device.



The process is absolutely similar to data transfer via Wi-Fi, the only thing is that the data transfer speed will be much higher, because the computer and the Android device are connected directly, instead of using the router as a gateway. In this case, the gateway will be the Android device itself. USB modem has the highest level of data transfer.

Backing up a single Partition (raw = exact bitwise copy of a partition)


Everything is similar to what was described above, it is only necessary to replace mmcblk0 with the corresponding Section. You can use the software in this particular case to view the contents of the copied Section. Depending on the file system: DiskInternals Linux Reader , Ext2Read , Ext2 File System Driver for Windows , Ext4Explore , plugin for Total Commander and ImDisk Virtual Disk Driver . You can also use software to recover data from individual partitions, for example, Recuva with the VHD Tool or command line tools included in the operating systems themselves.

Backing up a single Partition (tar = only files and folders are backed up)


In this case, the necessary partition is already mounted. (How to find the sections on Teclast x98 3g I described above.)
To see a list of all mounted partitions in the Cygwin Terminal, enter:
adb shell mount


Now you need to know where and which partition is mounted, for example, Firmware is mounted on / system, which is essentially a ROM.
In this case, you will have to open three Cygwin Terminals, due to limitations imposed by Android itself:

Open the first Cygwin Terminal and create a FIFO, for example, in / cach, and redirect tar to it:
adb forward tcp: 5555 tcp: 5555
adb shell
su
/ system / xbin / busybox mkfifo / cache / myfifo
/ system / xbin / busybox tar -cvf / cache / myfifo / system


You should do this because tar redirecting to stdout (c "-") does not work on Android and corrupts the saved file.

Open the second Cygwin Terminal:
adb forward tcp: 5555 tcp: 5555
adb shell
su
/ system / xbin / busybox nc -l -p 5555 -e / system / xbin / busybox cat / cache / myfifo


Open the third Cygwin Terminal:
adb forward tcp: 5555 tcp: 5555
cd / path / to / store / the / backup
nc 127.0.0.1 5555 | pv -i 0.5> system.tar


You can view the resulting tar file with Winrar, Total Commander, PeaZip, etc. Please note that you should not extract files or edit them, as the tar format retains the access and owner data for each file, which disappears when extracted to FAT / NTFS partitions.

This material was taken from the XDA .

Source: https://habr.com/ru/post/236397/


All Articles