-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiskRecoryTools.sh
More file actions
executable file
·121 lines (109 loc) · 3.27 KB
/
Copy pathdiskRecoryTools.sh
File metadata and controls
executable file
·121 lines (109 loc) · 3.27 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# Disk Recovery Automation Script
echo "====================================="
echo " Disk Recovery Automation Tool"
echo "====================================="
# Function to check if a tool is installed
check_tool() {
if ! command -v "$1" &> /dev/null; then
echo "Error: $1 is not installed. Installing it now..."
sudo dnf install -y "$1"
else
echo "$1 is already installed."
fi
}
# Function for TestDisk
run_testdisk() {
echo "Launching TestDisk for partition recovery..."
sudo testdisk
}
# Function for PhotoRec
run_photorec() {
echo "Launching PhotoRec for file recovery..."
sudo photorec
}
# Function for ddrescue
run_ddrescue() {
echo "Enter the damaged disk (e.g., /dev/sdX):"
read -r source_disk
echo "Enter the output image file path (e.g., /path/to/output.img):"
read -r output_img
echo "Enter the log file path (e.g., /path/to/logfile.log):"
read -r log_file
echo "Running ddrescue..."
sudo ddrescue "$source_disk" "$output_img" "$log_file"
}
# Function for extundelete
run_extundelete() {
echo "Enter the ext3/ext4 partition (e.g., /dev/sdX):"
read -r partition
echo "Unmounting the partition..."
sudo umount "$partition"
echo "Enter the directory to restore files to (e.g., /path/to/recover):"
read -r restore_dir
echo "Recovering deleted files with extundelete..."
sudo extundelete "$partition" --restore-all --output-dir "$restore_dir"
}
# Function for Foremost
run_foremost() {
echo "Enter the disk/partition to scan (e.g., /dev/sdX):"
read -r partition
echo "Enter the directory to save recovered files (e.g., /path/to/output):"
read -r output_dir
echo "Recovering files with Foremost..."
sudo foremost -i "$partition" -o "$output_dir"
}
# Function for Scalpel
run_scalpel() {
echo "Enter the disk/partition to scan (e.g., /dev/sdX):"
read -r partition
echo "Enter the directory to save recovered files (e.g., /path/to/output):"
read -r output_dir
echo "Recovering files with Scalpel..."
sudo scalpel "$partition" -o "$output_dir"
}
# Main Menu
while true; do
echo "Choose a recovery tool to run:"
echo "1. TestDisk (Partition Recovery)"
echo "2. PhotoRec (File Recovery)"
echo "3. ddrescue (Disk Cloning and Recovery)"
echo "4. extundelete (File Recovery for ext3/ext4)"
echo "5. Foremost (File Recovery - File Carving)"
echo "6. Scalpel (File Recovery - File Carving)"
echo "7. Exit"
read -rp "Enter your choice (1-7): " choice
case $choice in
1)
check_tool "testdisk"
run_testdisk
;;
2)
check_tool "testdisk" # PhotoRec is part of TestDisk
run_photorec
;;
3)
check_tool "ddrescue"
run_ddrescue
;;
4)
check_tool "extundelete"
run_extundelete
;;
5)
check_tool "foremost"
run_foremost
;;
6)
check_tool "scalpel"
run_scalpel
;;
7)
echo "Exiting the script. Goodbye!"
exit 0
;;
*)
echo "Invalid choice. Please enter a number between 1 and 7."
;;
esac
done