@echo off
color 0a
ECHO. 

rd /s /q backup > nul 2>&1

adb shell  "rm -rf /sdcard/backup "

adb shell "mkdir /sdcard/backup"

ECHO 正在备份 dtb 分区......

adb shell "dd if=/dev/dtb           of=/sdcard/backup/dtb.img" 

ECHO 正在备份 boot 分区......
adb shell "dd if=/dev/block/boot    of=/sdcard/backup/boot.img"

ECHO 正在备份 bootloader 分区......
adb shell "dd if=/dev/block/bootloader    of=/sdcard/backup/bootloader.img"

ECHO 正在备份 cri_data 分区......
adb shell "dd if=/dev/block/cri_data  of=/sdcard/backup/cri_data.img"

ECHO 正在备份 dtbo 分区......
adb shell "dd if=/dev/block/dtbo           of=/sdcard/backup/dtbo.img" 

ECHO 正在备份 env 分区......
adb shell "dd if=/dev/block/env          of=/sdcard/backup/env.img" 

ECHO 正在备份 keydata 分区......
adb shell "dd if=/dev/block/keydata         of=/sdcard/backup/keydata.img" 

ECHO 正在备份 metadata  分区......
adb shell "dd if=/dev/block/metadata   of=/sdcard/backup/metadata.img"

ECHO 正在备份 odm 分区......
adb shell "dd if=/dev/block/odm    of=/sdcard/backup/odm.img"

ECHO 正在备份 product  分区......
adb shell "dd if=/dev/block/product     of=/sdcard/backup/product.img"
 
ECHO 正在备份 recovery  分区......
adb shell "dd if=/dev/block/recovery     of=/sdcard/backup/recovery.img"

ECHO 正在备份 reserved  分区......
adb shell "dd if=/dev/block/reserved     of=/sdcard/backup/reserved.img"

ECHO 正在备份 rsv  分区......
adb shell "dd if=/dev/block/rsv    of=/sdcard/backup/rsv.img"

ECHO 正在备份 system 分区......
adb shell "dd if=/dev/block/system    | busybox gzip -4 > /sdcard/backup/system.img.gz"

ECHO 正在备份 vbmeta  分区......
adb shell "dd if=/dev/block/vbmeta    of=/sdcard/backup/vbmeta.img"

ECHO 正在备份 vendor   分区......
adb shell "dd if=/dev/block/vendor      | busybox gzip -4 > /sdcard/backup/vendor.img"

ECHO 正在备份 其它 分区......
adb shell "dd if=/dev/block/platform/skbackup  | busybox gzip -4 > /sdcard/backup/skbackup.img"
adb shell "dd if=/dev/block/platform/backup  | busybox gzip -4 > /sdcard/backup/backup.img"
adb shell "dd if=/dev/block/platform/cmccbackup  | busybox gzip -4 > /sdcard/backup/cmccbackup.img"
adb shell "dd if=/dev/block/platform/skmac   of=/sdcard/backup/skmac.img"
adb shell "dd if=/dev/block/platform/cmccmac   of=/sdcard/backup/cmccmac.img"
adb shell "dd if=/dev/block/platform/skparam   of=/sdcard/backup/skparam.img"

ECHO 正在上传备份的固件....

adb pull -p  /sdcard/backup  backup

ECHO 备份完成，固件存放位置为工具根目录backup文件！！！

pause>NUL