How to flash from a backup file. How to Backup Firmware Using SP Flash Tool

Many users of Android devices know that experiments with firmware, installation of various add-ons and fixes quite often lead to the inoperability of the device, which can only be fixed by installing the system cleanly, and this process involves completely clearing the memory of all information. In the event that the user has taken care of creating a backup copy of important data in advance, or even better - a full backup of the system, restoring the device to the “as it was before ...” state will take a few minutes.

There are many ways to back up certain user information or a full system backup. What is the difference between these concepts, for which devices it is advisable to use one or another method, will be discussed below.

A backup copy of personal information means the preservation of data and content generated by the user during the operation of the Android device. Such information includes a list of installed applications, photos taken by the device's camera or received from other users, contacts, notes, music and video files, browser bookmarks, etc.

One of the most reliable, and most importantly simple ways save personal data contained in the Android device is to synchronize data from the device's memory with cloud storage.

Full system backup

The above methods and similar actions allow you to save the most valuable information. But when flashing devices, not only contacts, photos, etc. are often lost, because manipulations with device memory sections involve clearing them of absolutely all data. To reserve the opportunity to return to the previous state of the software and data, you only need a full backup of the system, i.e., a copy of all or certain sections of the device’s memory. In other words, a complete clone or cast of the software part is created into special files with the ability to restore the device to a previous state later. This will require certain tools and knowledge from the user, but it can guarantee the complete safety of absolutely all information.

Where to store the backup? When it comes to long-term storage, in the best possible way cloud storage will be used. When saving information using the methods described below, it is advisable to use the memory card installed in the machine. If it is not available, you can save the backup files to the internal memory of the device, but in this case, it is recommended that you immediately copy the backup files to a more reliable place, such as a PC drive, immediately after creation.

Method 1: TWRP Recovery

From the user's point of view, the easiest way to create a backup is to use a modified recovery environment for this purpose - custom recovery. The most functional among such solutions is.


Method 2: CWM Recovery + Android App ROM Manager

As in the previous method, when creating an Android firmware backup, a modified recovery environment will be used, only from another developer - the ClockworkMod team -. In general, the method is similar to using TWRP and provides no less functional results - i.e. firmware backup files. At the same time, CWM Recovery does not have the capabilities necessary for many users to manage the process of creating a backup, for example, it is impossible to select individual partitions for creating a backup. But the developers offer their users a good Android application ROM Manager, resorting to the functions of which, you can start creating a backup directly from the operating system.


Method 3: Titanium Backup Android App

Titanium Backup is a very powerful yet easy to use system backup tool. With the help of the tool, you can save all installed applications and their data, as well as user information, including contacts, call logs, sms, mms, dots WI-FI access and other.

The advantages include the possibility of a wide range of settings. For example, a choice of applications is available, which and whose data will be saved. To create a full backup of Titanium Backup, you must provide root rights, that is, for those devices on which Superuser rights have not been obtained, the method is not applicable.

It is highly desirable to take care of a reliable place to save the created backups in advance. Inner memory smartphone cannot be considered as such, it is recommended to use a PC disk for storing backups, cloud storage Or in extreme cases, the microSD card of the device.

  1. Install and run Titanium Backup.
  2. At the top of the program there is a tab "Backups", let's go to it.
  3. After opening the tab "Backups", you need to call the menu "Batch Actions" by clicking on the button with the image of a document with a checkmark located in upper corner application screen. Or press the touch button "Menu" under the device screen and select the appropriate item.
  4. Next, press the button "START" located next to the option “Make r.k. all user software and system data".A screen appears with a list of applications to be backed up. Since a full backup of the system is being created, nothing needs to be changed here, you need to confirm that you are ready to start the process by clicking on the green checkmark located in the upper right corner of the screen.
  5. The process of copying applications and data will begin, accompanied by the display of information about the current progress and the name of the software component, which is saved in this moment time. By the way, the application can be minimized and continue using the device in normal mode, but, in order to avoid failures, it is better not to do this and wait until the copy is created, the process is quite fast.
  6. At the end of the process, a tab opens. "Backups". You may notice that the icons to the right of the app names have changed. Now these are peculiar emoticons of different colors, and under each name of the software component there is an inscription indicating that a backup copy has been created with the date.
  7. Backup files are stored at the path specified in the program settings.

    To avoid loss of information, for example, when formatting the memory before installing the system software, you should copy the backup folder to at least a memory card. This action can be done with any file manager for android. A good solution for carrying out operations with files stored in the memory of Android devices is.

Additionally

In addition to the usual copying of the backup folder created using Titanium Backup to a safe place, in order to reinsure against data loss, you can configure the tool so that copies are created immediately on the MicroSD card.


Method 4: SP FlashTool+MTK DroidTools

Using applications is one of the most functional ways that allows you to create a truly complete backup of all sections of the memory of an Android device. Another advantage of the method is the optional presence of root rights on the device. The method is applicable only for devices built on the Mediatek hardware platform, with the exception of 64-bit processors.

  1. To create a full copy of the firmware using SP FlashTools and MTK DroidTools, in addition to the applications themselves, you will need installed ADB drivers, drivers for the MediaTek boot mode, as well as an application (you can also use, but regular Notepad will not work). Download everything you need and unpack the archives into a separate folder on the C: drive.
  2. Turn on the device mode "USB Debugging" and connect it to the PC. To enable debugging,
    mode is activated first "For developers". To do this, we follow the path "Settings""About Device"- and tap five times on the item "build number".

    Then in the menu that opens "For developers" activate using the switch or checkmark the item "Allow USB Debugging", and when connecting the device to the PC, we confirm the permission to conduct operations using ADB.

  3. Next, you need to run MTK DroidTools, wait for the device to be detected in the program and press the button "Map of Blocks".
  4. The previous manipulations are the steps that precede the creation of the scatter file. To do this, in the window that opens, click the button "Create scatter file".
  5. And choose the way to save the scatter.

  6. The next step is to determine the address that SP FlashTools will need to specify when determining the range of blocks in the reader's memory. Open the scatter file obtained in the previous step in the Notepad ++ program and find the line partition_name: CACHE: , under which a line with the parameter linear_start_addr is located just below. The value of this parameter (highlighted in yellow in the screenshot) must be written or copied to the clipboard.
  7. Direct reading of data from the device's memory and saving them to a file is carried out using the SP FlashTools program. Launch the application and go to the tab Readback. The smartphone or tablet must be disconnected from the PC. We press the button Add.
  8. There is only one line in the window that opens. Double click on it to set the reading range. Select the path where the future memory dump file will be saved. The file name is best left unchanged.
  9. After specifying the save path, a small window will open, in the field Length: which you need to enter the value of the linear_start_addr parameter obtained in step 5 of this instruction. After entering the address, press the button "OK".

    We press the button "Read Back" tab of the same name in SP FlashTools and connect the switched off (!) device to the USB port.

  10. In the event that the user has taken care of installing the drivers in advance, SP FlashTools will automatically detect the device and begin the reading process, as evidenced by the filling of the blue progress bar.

    Upon completion of the procedure, a window is displayed "Readback OK" with a green circle, inside which is a confirmation checkmark.

  11. The result of the previous steps is the file ROM_0, which is a complete dump of the internal flash memory. In order to make it possible to carry out further manipulations with such data, in particular, upload firmware to the device, several more operations are needed using MTK DroidTools.
    We turn on the device, boot into Android, check that "USB Debugging" turned on and connect the device to USB. Launch MTK DroidTools and go to the tab root, backup, recovery. Need a button here "Make a backup from the ROM_ flash drive", press it. Open the file obtained in step 9 ROM_0.
  12. Immediately after pressing the button "Open" the process of splitting the dump file into separate partition images and other data needed for recovery will begin. Process progress data is displayed in the log area.

    When the procedure for dividing a dump into separate files complete, the inscription will be displayed in the log field "mission completed". This completes the work, you can close the application window.

  13. The result of the program's operation is a folder with image files of the device's memory sections - this is our backup copy of the system.

Method 5: System backup using ADB

If it is impossible to use other methods or for other reasons, to create a complete copy of the memory sections of almost any Android device, you can use the OS developers toolkit - the component Android SDK– . In general, ADB provides all the possibilities for carrying out the procedure, you only need root rights on the device.

It should be noted that the method under consideration is quite laborious, and also requires the user to have a fairly high level of knowledge of ADB console commands. To facilitate the process and automate the introduction of commands, you can turn to a wonderful shell application, this automates the process of entering commands and saves a lot of time.

  1. The preparatory procedures are to get root rights on the device, enable USB debugging, connect the device to usb port, installing ADB drivers. Next, download, install and run the ADB Run application. After the above is done, you can proceed to the procedure for creating partition backups.
  2. We launch ADB Run and check that the device is detected by the system in the desired mode. Item 1 of the main menu - "Device attached?", in the drop-down list we perform similar actions, again select item 1.

    A positive answer to the question of whether the device is connected in ADB mode is the response of ADB Run to the previous commands in the form of a serial number.

  3. For further manipulations, it is necessary to have a list of memory sections, as well as information about which “disks” - /dev/block/ partitions have been mounted. Using ADB Run, getting such a list is pretty easy. Go to the section "Memory and Partitions"(item 10 in the main menu of the application).
  4. In the menu that opens, select item 4 - "Partitions /dev/block/".
  5. A list is opened with a list of methods that will attempt to read the required data. Let's try each item in order.

    If the method fails, the following message is displayed:

    Execution will have to continue until the full list of partitions and /dev/block/ appears:

    The received data must be saved by any accessible way, automatic function Saving in ADB Run is not provided. The most convenient way to fix the displayed information is to create a screenshot of the window with a list of sections.

After we have downloaded everything you need, you can, for example, create an Android folder in the root and expand the unpacked contents of the archives into folders, i.e. drivers to the Drivers folder, Platform Tools to a separate folder, SP Flash Tool into a separate one, MTK Droid Tools is also into a separate one.

Next, enable Developer Mode on your device and activate USB debugging. Those. first go to Settings -> About phone (About device) and click several times (5-7) on the inscription "Build number", until a message appears that Developer Mode is activated. Next, go to the menu Settings -> For developers and put a tick on "Debugging via USB":

After that, we connect the device to the PC and install the ADB drivers (that is, either by running AdbDriverInstaller.exe from the archive, or by opening the device manager and manually specifying the path to the drivers in the Android ADB driver x64 folder for an unknown device). The result should look like this (Device Manager):

The Android ADB Interface device in Device Manager confirms that we are all set for the next step.

We wait until the device is detected in it and press the "Map of blocks" button:

After that, click the "Create scatter file" button and save the resulting file (for me it was called MT6582_Android_scatter.txt) to disk. At this stage of preparation is completed and you can proceed directly to reading the data.

Open the resulting file in Notepad ++ or Word (note that a regular notepad will not work) and find the line partition_name: CACHE in it:

And remember what you have written in the linear_start_addr column, in this case this is 0x3E900000.

We disconnect the phone from the PC and turn it off, i.e. hold the power button and select "Power off" in the menu, you can also disconnect and insert the battery. Next, run the SP Flash Tool and go to the Readback tab in it. Next, click the Add button. As a result, one row will appear in the table:

We click on it, we are prompted to select the location to save the ROM_0 file, select the folder where we want to save it and on the next screen in the Length field enter the number we remembered earlier (linear_start_addr):

The end result should be something like this:

Then we connect the switched off phone (!) To the PC. At this point, it is advisable to open Device Manager. So far, we do not press any buttons in the SP Flash Tool on this screen!

At the time of connection, an unknown MT65xx PreLoader device will be detected in you and the OS will offer you to install drivers for it. The picture below clearly shows this. It is better to open the device manager immediately before connecting the phone in order to “catch” the moment the MT65xx PreLoader appears. If the device appears, and the OS does not offer to automatically install the drivers, then this must be done manually by right-clicking on the MT65xx PreLoader device.

We select "Search for drivers on this computer" and specify the folder in which the unpacked contents of the mtk_xp_vista_7_8_x32_x64.zip archive are located (that is, by this time you should unpack the archive somewhere). After the drivers are successfully installed, the picture in the device manager should change to this:

If the drivers are installed, you can proceed to the next step. Please note that when the phone is connected, the Preloader USB VCOM Port may appear for only a few seconds - this is normal, our task at this stage is to install the phone drivers so that it is identified as the Preloader USB VCOM Port, and not the unknown device MT65xx PreLoader. If you suddenly did not have time to install the drivers, and the phone turned on, we take out the battery, disconnect the phone, insert the battery, connect the phone and repeat the procedure.

As soon as we are convinced that the drivers are installed, we disconnect the phone from the PC. We turn it off, in the open SP Flash Tool we press the Readback button and connect the switched off phone to the PC. After that, we will start the process of reading the firmware from the phone:

Many write about the difficulties that arise precisely at this step. I'll try to explain a little more. After you press the Readback button - SP Flash Tool goes into standby mode for connecting the phone, i.e. it is assumed that before that you managed to catch the moment when your turned off phone is defined as MT65xx PreLoader and install drivers on it so that you have Preloader USB VCOM Port in COM ports. If suddenly, for some reason, the SP Flash Tool wrote about an error, or the phone did not have time to connect, the following method can help (everything described is true only if you installed the drivers correctly and when you connect the phone you get Preloader USB VCOM Port): turn off the phone from the PC, take out the battery, press the Readback button, connect the phone with the battery pulled out. A red bar (Download) will go to the SP Flash Tool, during this time we quickly insert the battery back, if we have time, then a blue Readback bar with percentages will go, as in the picture:

We wait until the process is completed. Creating a backup can take 10-15 minutes. We just look at the running interest and do not touch anything 😉 At the end of the reading procedure, you will see the inscription Readback Ok:

While we are doing Backup, it's time to explain what a scatter file is and what the ROM_0 file is, which we will get at the output. The phone's memory is a regular EMMC Flash, which is divided into certain sections. A scatter file is a section description file (for example, Scatter has sections PRELOADER, RECOVERY, LOGO, ANDROID, etc.). The purpose of partitions is different, for example, in Recovery - contains recovery image, in logo - the logo used when the system boots, in Android - the system image, etc. The ROM_0 file that we get as output is essentially a solid EMMC Flash dump in one file. But in order to use the received firmware backup, for example, to restore another similar device, we will still need to split it into sections. Here I will describe several ways how to do it. The first and most common is through MTK Droid Tools. Let's say we already have a ROM_0 file made with the SP Flash Tool.

We turn on the power of the device (phone) and let it boot, after which we restart MTK Droid Tools (the USB debugging mode on the phone, of course, must be enabled, and the ADB drivers are installed on the PC), go to the root, backup, recovery tab and press the button "Create backup from ROM_ flash drive":

We select the ROM_0 we got at the previous step and in the log window we see something like the following:

- Save folder on the computer: E:\Android\MtkDroidTools\backups\KINGSING_S1_141117_ForFlashtoolFromReadBack_150512-005322\
— scatter is saved in the file:
E:\Work\Megaphone Login Plus\MtkDroidTools\backups\KINGSING_S1_141117_ForFlashtoolFromReadBack_150512-005322\MT6582_Android_scatter.txtCopy completed
- preloader.bin ... copied ... cut OK
- MBR ...copied
- EBR1 ...copied
- pro_info ...copied
- nvram.bin ...copied
- protect_f ...copied
- protect_s ...copied
- seccfg ...copied
- uboot.bin ...copied
- boot.img ... copied

Well, etc. Now in the save folder, I have this E:\Android\MtkDroidTools\backups\ we have a folder with a full backup of our firmware, divided into sections (i.e. each section in a separate file):

This completes the process of creating a backup of the firmware. If you just wanted to learn how to backup firmware using the SP Flash Tool and you succeeded, you can not read further.

For advanced

But what if MTK Droid Tools "does not see" the phone? Or is it impossible to create a scatter file or split the resulting ROM_0 file into sections? How to get a partition map and is it possible to "cut" the ROM_0 file manually? There is such a possibility. To get a partition map on MTK 65xx, you need to give a command in the ADB console - i.e. run adb shell in the console and type this command there:

If suddenly the phone for some reason is not seen through ADB (in this case, I advise you to read the ADB manual, there may be a problem in the VEN_ID of the device and you just need to register it in %USERPROFILE%\.android\adb_usb.ini, then the same command can be given in the phone itself by installing Terminal Emulator for Android from Google Play:

As you can see, the result is exactly the same and the linear_start_address of the cache section can be taken from here. Yes, by the way, in new devices, for example, based on MTK 6752, such as Beeline Pro, ZTE Q Lux, etc. The partition map can be obtained with cat /proc/partinfo. MTK Droid Tools does not work with these devices at all.

We now have a method for obtaining the start address of the cache partition, which is needed to obtain ROM_0 using the SP Flash Tool. We also know the addresses (offsets) and sizes of each of the partitions. Those. to "cut" ROM_0 into sections - we do not need to use MTK Droid Tools at all. This can be done "by hand" in any Hex editor that supports the function of selecting and saving a block to a file (I use the console HIEW). Well, as an example, let's "cut" the Recovery partition from the resulting ROM_0 file.

We know (from scatter or dumchar_info) its linear_start_addr: 0x4180000 and partition_size: 0x1000000. Open ROM_0 in HIEW and navigate to 0x4180000. Those. in the console we do hiew32 ROM_0, then press F5 and drive in the address of the beginning of the partition - 4180000:

As you can see, at 4180000 we have the ANDROID! signature, which tells us that we are on the right track 😉 The address of the end of the partition is calculated as linear_start_addr+partition_size-1 = 0x517FFFF in our case. Press in HIEW * (asterisk on the additional keyboard) to start highlighting the block (if you move the up / down / right / left arrows, we see how the block starts to be highlighted) and either go down to 0x517FFFF, or do it through F5:

And we finish the selection of the block, again through the “gray” * (on the additional keyboard). After that, press F2 - Put block (saving the block to a file):

And we have a recovery partition. In the same way, you can cut any other partition from ROM_0. As you understand, we do not need the MTK Droid Tool at all.

To simplify the procedure, you can also write a script / program that will do this automatically for all sections, but to be honest, I don’t have enough time for this, and this task doesn’t arise so often, so HIEW is enough for me for these purposes .

p.s. That's all for now ... the post turned out to be a "draft version", because was written in hastily, perhaps later I will supplement it if there are any incomprehensible moments. And of course, as always, I will be happy to hear your comments and questions...

p.p.s. As they managed to correct me a little, /proc/dumchar_info does not contain linear_start_addr from scatter, but physical_start_addr. Those. in the above example for the partition with recovery we have:

linear_start_addr: 0x4180000
physical_start_addr: 0x2D80000
partition_size: 0x1000000

And in /proc/dumchar_info we see exactly the physical_start_addr in the StartAddr column. But if we look at the size of the first section (preloader), it becomes clear how to translate physical_start_addr into linear_start_addr, if we add 0x1400000 to 0x2D80000 (this is just the size of the preloader), then it just turns out 0x4180000.

Hello Habrahabr.

general information

This guide is intended to help you create a full backup of your device (all memory with all partitions) or a single partition (including sdcards, etc.) directly to your computer:
  • At the level of Blocks of memory (using the dd command): for individual partitions or the entire memory (all partitions). Backup copy will always be the same size as the saved partition.
  • At the File level (using tar commands): only for certain sections. The copy will only contain the files and folders that are on the device, thus taking up much less space depending on how full the partition is.

This instruction is applicable when the device is turned on or in ClockworkMod Recovery (in these cases, ADB will work, in fastboot mode this instruction not applicable). Unless otherwise noted, all commands are intended for use on Windows. The same goes for Linux with Unix.

Requirements

  • rooted Android device;
  • Installed Busybox on the device;
  • If you are using Linux / OS X, you already have necessary tools, for Windows, download Cygwin and install netcat, pv and util-linux with it, selecting them during installation (I’ll add on my own that it’s better to use the terminal from Cygwin mintty.exe than the native Windows cmd.exe, since copying speed the first one reached 3-4 MB / s, and cmd.exe - a maximum of 400 kb / s);
  • Installed ADB;
  • Make sure adb.exe is in your PATH. See and , or use the Path Manager ;
  • Enabled USB debugging mode on the device and the appropriate drivers installed in Windows. Typing "adb devices" in terminal should show your device.

Partitions in the device

Now you need to define the partitions 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 you only need to use dd to copy the entire memory.

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

An example of what should appear in response to your input in the terminal.

127|[email protected]:/ # 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
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
[email protected]:/ # 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 partitions.

All phone memory -> /dev/block/mmcblk0 (although, on some phones, this may be sdcard).
Sections -> it all depends 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.

Concerning Teclast x98 3g and the case when the device does not boot (bootloop). It is very important that USB debugging mode is enabled before all this happens. 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 show that the charging process is in progress, only then, even when it is turned off, it will be possible to work with the device through the terminal and adb.

Launch Cygwin Terminal and type (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 next line left. At the moment, the machine is waiting for the Block to be transmitted over the network.

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 will begin to increase until the entire block you have selected is completely copied. Now you have a complete backup of the device in raw format. You can see all the content in the copied Block using gptfdisk available for Windows, Linux and other operating systems (official site or ). You can do the same with ClockworkMod Recovery, but first you need to 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.

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

You can use ADB over WiFi in the same way as WiFi ADB.

Entire memory backup (via WiFi)

Author citation: Nandroid directly to computer w/o sdcard .

Necessary:

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

It's good practice to copy myfifo to /cache rather than /data, as you can accidentally overwrite important data if you use raw data for recovery.

Launch Cygwin Terminal and type:

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 type:

adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo

Some remarks:

  • FIFOs can only be done on Linux Native file systems, FAT will not work for this;
  • The process of reading a Partition from a device does not modify it in any way.

Full memory backup (via USB tethering or Wi-Fi tethering)

To do this, disable all network connections on the computer, in addition, with which you will carry out the copying process.
Once you connect a computer to an Android device, you can view the computer's IP and device's IP in "Connection Properties". IP - will be the IP of the computer itself, and Gateway will contain the IP of the Android device.
  • Wi-Fi modem: Computer< - Wi-Fi --->Android device< - 3G --->Internet
  • USB modem:
    A computer< - USB --->Android device< - Wi-Fi --->Internet
    Computer< - USB --->Android device< - 3G --->Internet

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

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

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

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

In this case, an already mounted partition is needed. (I described how to find partitions on Teclast x98 3g above.)
To see a list of all mounted partitions in the Cygwin Terminal, type:

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

Open the first Cygwin Terminal and create a FIFO in /cach for example 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 have to do this because redirecting tar to stdout (c "-") doesn't work on Android and corrupts the saved file.

Open a 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 a 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. Note that you should not extract or edit files, as the tar format retains access and ownership information for each file, which disappears when extracted to FAT/NTFS partitions.

Tags: Add tags

Hello Habrahabr.

general information

This guide is intended to help you create a full backup of your device (all memory with all partitions) or a single partition (including sdcards, etc.) directly to your computer:
  • At the level of Blocks of memory (using the dd command): for individual partitions or the entire memory (all partitions). The backup will always be the same size as the partition being saved.
  • At the File level (using the tar command): for individual partitions only. The copy will only contain the files and folders that are on the device, thus taking up much less space depending on how full the partition is.

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

Requirements

  • Rooted Android device;
  • Installed Busybox on the device;
  • If you are using 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 will add that it is better to use the terminal from Cygwin mintty. exe than cmd.exe, which is native to Windows, since the copy speed of the former reached 3-4 MB / s, while cmd.exe had a maximum of 400 kb / s) ;
  • Installed ADB;
  • Make sure adb.exe is in your PATH. See and , or use the Path Manager ;
  • Enabled USB debugging mode on the device and the appropriate drivers installed in Windows. Typing "adb devices" in terminal should show your device.

Partitions in the device

Now you need to define the partitions 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 you only need to use dd to copy the entire memory.

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

An example of what should appear in response to your input in the terminal.

127|[email protected]:/ # 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
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
[email protected]:/ # 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 partitions.

All phone memory -> /dev/block/mmcblk0 (although, on some phones, this may be sdcard).
Partitions -> 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.

Concerning Teclast x98 3g and the case when the device does not boot (bootloop). It is very important that USB debugging mode is enabled before all this happens. 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 show that the charging process is in progress, only then, even when it is turned off, it will be possible to work with the device through the terminal and adb.

Launch Cygwin Terminal and type (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 machine is waiting for the Block to be transmitted over the network.

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 will begin 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 content in the copied Block using gptfdisk available for Windows, Linux and other operating systems (official site or ). You can do the same with ClockworkMod Recovery, but first you need to 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.

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

You can use ADB over WiFi in the same way as WiFi ADB.

Entire memory backup (via WiFi)

Author citation: Nandroid directly to computer w/o sdcard .

Necessary:

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

It's good practice to copy myfifo to /cache rather than /data, as you can accidentally overwrite important data if you use raw data for recovery.

Launch Cygwin Terminal and type:

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 type:

adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo

Some remarks:

  • FIFOs can only be done on Linux Native file systems, FAT will not work for this;
  • The process of reading a Partition from a device does not modify it in any way.

Full memory backup (via USB tethering or Wi-Fi tethering)

To do this, you must disable all network connections on the computer, except for the one with which you will carry out the copying process.
Once you connect a computer to an Android device, you can view the computer's IP and device's IP in "Connection Properties". IP - will be the IP of the computer itself, and Gateway will contain the IP of the Android device.
  • Wi-Fi modem: Computer< - Wi-Fi --->Android device< - 3G --->Internet
  • USB modem:
    A computer< - USB --->Android device< - Wi-Fi --->Internet
    Computer< - USB --->Android device< - 3G --->Internet

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

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

Everything is similar to what was described above, only you need to replace mmcblk0 with the appropriate Section. You can use in this particular case the software to view the contents of the copied Section. Depending on the file system: DiskInternals Linux Reader, plugin for Total Commander and ImDisk Virtual Disk Driver. You can also use partition recovery software, such as Recuva in conjunction with the VHD Tool, or the command line tools included with the operating systems themselves.

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

In this case, an already mounted partition is needed. (I described how to find partitions on Teclast x98 3g above.)
To see a list of all mounted partitions in the Cygwin Terminal, type:

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

Open the first Cygwin Terminal and create a FIFO in /cach for example 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 have to do this because redirecting tar to stdout (c "-") doesn't work on Android and corrupts the saved file.

Open a 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 a 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. Note that you should not extract or edit files, as the tar format retains access and ownership information for each file, which disappears when extracted to FAT/NTFS partitions.

Tags:

  • Android
  • nandroid backup
  • Saving data
  • Translation
Add tags