How to make a nandroid backup device directly to a computer, bypassing sdcard

Hello, Habrahabr.

It so happened that I needed to create a full copy of the Android device, which completely lacked the commonly used tools 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, because I used this instruction to create a backup'a tablet Teclast x98 3g .

general information


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

  • At the level of memory blocks (using the dd command): for individual partitions or the entire memory (all partitions). The backup will always be the same size as the saved partition.
  • At the File Level (using the tar command): for specific sections only. The copy will contain only the files and folders that are on the device, thus taking up much less space, depending on how much the section is full.


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

Requirements


  • Rooted Android device;
  • Busybox installed on the device;
  • If you use Linux / OS X, you already have the necessary tools, for Windows, download Cygwin and install netcat, pv and util-linux with it, choosing them during installation (I’ll add that it’s better to use the terminal from Cygwin mintty. exe than the native Windows cmd.exe, since the first copy speed reached 3-4 MB / s, and cmd.exe - a maximum of 400 kb / s) ;
  • Installed ADB;
  • Make sure adb.exe is in the PATH variable. Look here and here , or use the Path Manager ;
  • Enabled USB debugging mode on the device and the corresponding drivers installed in Windows. Entering “adb devices” in the terminal should show your device.


Sections in the device


Now you need to identify the sections and blocks on your device that you want to make a copy of. You can use the tar or dd commands to copy a single partition, while only dd can be used to copy all the 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 mmcblk0p2 12 32768
179 13 32768 mmcblk0p3
179 mmcblk0p4 14 131072
179 15 131072 mmcblk0p5
179 mmcblk0p6 16 131072
179 17 786432 mmcblk0p7
179 mmcblk0p8 18 262144
179 19 1048576 mmcblk0p9
259 0 27742188 mmcblk0p10
179 30 2048 mmcblk0boot1
179 20 2048 mmcblk0boot0
179 0 30657536 mmcblk1
179 1 30657504 mmcblk1p1


Typically, 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 partitions.

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

Backup all memory (via adb)


Connect the phone with USB debugging enabled to the computer.

As for Teclast x98 3g and the case when the device does not boot (bootloop). It is very important that before all this happened, the debugging mode via USB was turned on. Turn off the tablet completely, disconnect all cables, give 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 indicate that the charging process is in progress, only then, even when turned off, you can work with the device through the terminal and adb.

Launch Cygwin Terminal and enter (replace mmcblk0 if necessary):
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 blinking cursor on the next line on the left. At the moment, the device is waiting for the transfer of the Block 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 starts 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 OS ( official site or SourceForge ). You can do the same with ClockworkMod Recovery, but you must first mount the / system partition, since the BusyBox included in ClockworkMod does not have netcat, so you need to use netcat from the / system partition of your device.

Using certain tools on Linux, you can modify and retrieve the required Partitions from the entire Block.

You can use ADB via WiFi, similar toWi-Fi ADB .

Backup all memory (via WiFi)


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

It is necessary:
  • Installed FTP server on a computer or other device;
  • User with password;
  • The installed port for the FTP server is 21 by default, but in this example 40 is used;
  • The home directory of the user with write permissions.


The rule of thumb 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:
  • FIFOs can only be done on Linux Native file systems; FAT is not suitable for this;
  • The process of reading a Section from a device does not modify it in any way.


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


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

  • Wi-Fi modem: Computer <- Wi-Fi ---> Android device <- 3G ---> Internet
  • USB modem:
    Computer <- USB ---> Android device <- Wi-Fi ---> Internet
    Computer <- USB ---> Android device <- 3G ---> Internet


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. The USB modem has the highest level of data transfer.

Backing up one Partition (raw = exact bitwise copy of the partition)


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

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


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


Now you need to know where and which partition is mounted, for example, Firmware is mounted in / system, which is essentially ROM.
In this case, you will have to open three Cygwin Terminal, due to restrictions 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 must do this because redirecting tar 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 using Winrar, Total Commander, PeaZip, etc. Please note that you should not extract files or edit them, since the tar format saves access and owner data for each file, which disappears when extracted to FAT / NTFS partitions.

This material was taken from XDA .

Also popular now: