How to Backup and Restore Android Partitions via ADB

backup android partition adb

backup android partition adb

In this guide, we will show you the steps to take a backup of numerous partitions on your Android device as well as restore them- all via ADB Commands. If you are stepping into custom development, then there’s always an iota of a chance of things going south. From the device ending into a bootloop or a softbrick state to even getting hard bricked, quite a few things could go wrong in this ecosystem if not done correctly.

Fortunately, in most cases, you could easily bring your device back to life by flashing the Fastboot ROM/stock firmware/EDL firmware. But even if the device is up and running, it might happen that some of the device’s partitions remain corrupted. And that is the worst thing that could happen with your device. This is because there might exist no method whatsoever to bring those partitions back to their default state [well, until you go to the service center and shell out hefty bucks].

For instance, if the persist partition gets corrupted, then the fingerprint will no longer work on your device. Likewise, corruption of the EFS partition will result in the IMIE being nullified [either will be either all blank or 0]. And as opposed to general consensus, flashing the stock firmware wouldn’t repair this partition. More importantly, never ever ask another user to share their EFS or Persist partition, even if they own the same device, are on the same OS version, and belong to the same region.

This is because it will lead to data overlapping and the entire issue will only escalate to a much more complicated level. So what else could be done? Well, in such cases, your best bet is to restore the partitions that you have backed up from your device via ADB Commands.

[It’s obvious that if you haven’t taken a backup yet and the partitions have already got corrupted, then there’s no need to do so now because backing up and restoring the corrupt partition wouldn’t make any sense whatsoever. On the flip side, it will only it will further degrade the issue.]. So with that in mind, let’s now make you aware of the steps to take a backup of Android partitions and restore them via ADB Commands. Follow along.

How to Backup and Restore Android Partitions via ADB

While the process is fail-safe and wouldn’t lead to any data loss, still take a backup of all the data on your device, just to be on the safer side. Moreover, we will be listing two different methods to get this job done- the automatic and the manual approach.

The former is the shorter and easier of the two whereas the latter gives you more granular control over the entire process [though it is a tad bit lengtheir]. Go through both of these methods once and then try the one that is in sync with your requirements.

STEP 1: Download Android SDK Platform Tools

First off, get hold of Android SDK Platform Tools and extract them onto your PC. This will give us the required ADB binaries which is needed to execute the ADB Commands.

platform tools

STEP 2: Root Device

Next up, you’ll have to obtain administrative rights by rooting your device via Magisk. For that, you may refer to our detailed guide on How to Root any Android Device via TWRP OR How to Root Android via Magisk.

STEP 3: Enable USB Debugging

You’ll now have to enable USB Debugging on your device so that your PC is able to identify the connected device in ADB Mode. Here’s how it could be done:

  1. Head over to Settings > System > About Phone > Tap on Build Number 7 Times.
  2. Then go to Settings > System > Developer Options > Enable the USB Debugging.dsu sideloader

STEP 4: Grant SuperUser Request

  1. Head over to platform-tools, type in CMD in its address bar and hit Enter.
  2. This will launch Command Prompt. Now type in the below command in it:
    adb shell
  3. You’ll get a prompt on your device, tap Allow/OK. Then type in below command:
    su

    superuser request magisk

  4. You’ll get a SuperUser Request, tap Grant. With this, root privilege has been granted.

STEP 5A: Backup Android Partition via ADB [Automatic]

  1. Type in the below command to bring a list of all partitions on your device
    ls -la /dev/block/by-name
  2. Note down the partition name whose backup you want to take [let’s say persist].backup partition android adb
  3. Now type in the below command, replacing partition with its actual name.
    su -c dd if=/dev/block/bootdevice/by-name/partition of=/sdcard/partition.img
  4. For instance, if you want to take a backup of the persist partition, then the command will be:
    su -c dd if=/dev/block/bootdevice/by-name/persist of=/sdcard/persist.img

    backup efs root
    Reference Image
  5. The Persist partition [persist.img] will be backed up on your device. Transfer it to your PC.

STEP 5B: Backup Android Partition via ADB [Manual]

  1. Type in the below command to bring a list of all partitions on your device.
    ls -la /dev/block/by-name
  2. Note down the sda address for the desired partition.backup partition android adb
  3. For instance, if we want to take a backup of EFS partition, then it will be sda9.
  4. Now use the below command, replacing location with the sda address and partition with the partition name.
    dd if=location of=/sdcard/partition.img bs=4096
  5. In our case [EFS partition], the aforementioned command will transform to:
    dd if=/dev/block/sda9 of=/sdcard/efs.img bs=4096

    backup partition android adb

  6. The efs.img will be placed in your device’s Internal Storage. Transfer it to your PC.

How to Restore Partitions on Android via ADB

Now that you have a taken a backup of the desired partition, let’s now proceed ahead and restore it. Again we are reiterating the fact that you should only restore the backed up partition that you have made on your device, you shouldn’t use the one shared by any other user, even though it is of the same firmware version and same device. Keeping that in mind, let’s get started.

  1. Download and extract the Android SDK Platform Tools on your PC.
  2. Then enable USB Debugging and connect your device to PC via USB.Blank Vbmeta Samsung
  3. Now transfer the backed up IMG file to the platform-tools folder.
  4. Then, open the Command Prompt inside the platform-tools folder.
  5. Now type in below command to restore the partition on your device
    fastboot flash partition-name file-name.img
  6. For example, if we wish to restore the EFS Partition, the command will be
    fastboot flash efs efs.img
  7. Finally, reboot to the OS via the below command:
    fastboot reboot

That’s it. These were the steps to backup partitions on your Androidd device via ADB Commands. Likewise, we have also listed the steps to restore it. If you have any queries concerning the aforementioned steps, do let us know in the comments. We will get back to you with a solution at the earliest.


Leave a Reply

Your email address will not be published. Required fields are marked *