Suppose I plan to flash my recovery with TWRP/CWM, but then later suppose I would like to move back to the stock recovery. Is it possible to take a backup of stock recovery just like we can take a backup of our ROM?
EXTRACTING BOOT.IMG FROM STOCK ROM or OTHER IMG LIKE RECOVERY ETC.
1. Download adb required tools.
3. Phone Drivers (for other phones google it out)
for spreadtrum phones: SCI-Usb-Jungo v4 (download here) or SCI-USB2Serial v184.108.40.206 (download here)
4. Android Phone + Usb cables
STEPS: OPEN cmd window in adb folder
type the ff:
adb devices adb shell su cat /proc/mtd
Now from your screen look at your files and you see mtd10 has your recovery.img
dev: size erasesize name mtd0: 00040000 00020000 "misc" mtd10: 00500000 00020000 "recovery" mtd12: 00280000 00020000 "boot" mtd13: 04380000 00020000 "system" mtd14: 04380000 00020000 "cache" mtd15: 04ac0000 00020000 "userdata"
Once u see it's LOCATION in which in this sample is in mtd10 type:
cat /dev/mtd/mtd10 > /sdcard/mtd10.img or
cat /dev/mtd/mtd10 > /sdcard/recovery.img
Generic Backup/ Restore
If you are root you can backup/ restore all partitions (not only recovery) with native tools.
To list all mountable partitions and block devices use
adb shell su find /dev | grep by-name$
On my system I get
/dev/block/platform/soc/1d84000.ufshc/by-name back (this is very device specific and yours may look different).
Now You can list
ls this path to show all mountable partitions.
ls -al --color /dev/block/platform/soc/1d84000.ufshc/by-name/
Or all in one command
ls -al --color $(find /dev|grep by-name$)
Armed with this information you can, as root, backup all partitions. Just use the
dd (part of every android toolboox/ toyboox e.g.:
dd if=/dev/block/platform/soc/1d84000.ufshc/by-name/recovery of=/sdcard/Download/recovery.img.dd
Warning Data lost possible! Don't use until You understand all
In many cases you can also restore with the
dd tool, e.g:
dd if=/sdcard/Download/recovery.img.dd of=/dev/block/platform/soc/1d84000.ufshc/recovery
The key point is to boot a custom recovery partition such as TWRP without installing it. For instance with an HTC device you would use the platform adb tools and run this command from a terminal in Windows:
fastboot boot twrp.img
This remote-boots the custom recovery partition so you leave the stock recovery partition intact.
Now you root the phone.
Reboot the phone.
Use dd command to copy the recovery partition.
If you have already flashed a recovery partition then it's too late. You will have to find a stock recovery partition for your phone somewhere on the interweb.