-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_critical_partitions.sh
executable file
·74 lines (68 loc) · 1.36 KB
/
backup_critical_partitions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Path to Preloader, loader
PRELOADER="./sources/preloader_penangf.bin"
LOADER="./sources/MT6768_USER.bin"
# Backup out dir
BACKUP_DIR="backups"
mkdir -p "$BACKUP_DIR"
PARTITIONS=(
"misc"
"para"
"expdb"
"frp"
"hw"
"utags"
"utagsBackup"
"vbmeta_a"
"vbmeta_system_a"
"vbmeta_vendor_a"
"vbmeta_b"
"vbmeta_system_b"
"vbmeta_vendor_b"
"md_udc"
"metadata"
"nvcfg"
"nvdata"
"persist"
"protect1"
"protect2"
"seccfg"
"md1img_a"
"spmfw_a"
"scp_a"
"sspm_a"
"gz_a"
"lk_a"
"boot_a"
"vendor_boot_a"
"dtbo_a"
"tee_a"
"sec1"
"proinfo"
"boot_para"
"nvram"
"rfcal"
"cid"
"sp"
"elable"
"prodper"
"kpan"
"flashinfo"
)
# backup partiotion create command
backup_partition() {
local partition="$1"
local output_file="$BACKUP_DIR/${partition}.img"
echo "Backup partition - [$partition]"
mtk r "$partition" "$output_file" --preloader "$PRELOADER" --loader "$LOADER"
if [[ $? -ne 0 ]]; then
echo "Error: Failed to create partition backup $partition."
else
echo "Backup of $partition successfully saved to $output_file."
fi
}
# run backup all partitions
for partition in "${PARTITIONS[@]}"; do
backup_partition "$partition"
done
echo "Backup completed. All files saved to $BACKUP_DIR."