]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/usb/src/scripts/restore/main
Add new usb rescue key code
[bacula/rescue] / rescue / linux / usb / src / scripts / restore / main
1 #!/bin/sh
2
3
4 raidiskdone=""
5 if [ -f noprompt ];then
6 rm noprompt
7 fi
8
9 if [ -f badblocksnoprompt ];then
10 rm badblocksnoprompt
11 fi
12
13 if [ -f partitionscript ];then
14 rm partitionscript
15 fi
16 if [ -f formatallscript ];then
17 rm formatallscript
18 fi
19 touch formatallscript
20
21 if [ -f added_disks ];then
22 rm added_disks
23 fi
24 touch added_disks
25   if [ -f checkraidtemp ];then
26   rm checkraidtemp
27   fi
28     touch checkraidtemp
29       if [ -f added_disks ];then
30       rm added_disks
31       fi
32 touch added_disks
33 if [ -f fulldisks ];then
34 rm fulldisks
35 fi
36 if [ -f checkraidtemp ];then
37 rm checkraidtemp
38 fi
39 if [ -f raidisks ];then
40 rm raidisks
41 fi
42 touch raidisks
43 touch checkraidtemp
44 touch fulldisks
45
46   if [ -d working ];then
47   rm -r working
48   fi
49 cp -r ../clients/$clientdir working
50
51 if [ -f nozen ]; then 
52 DIALOG=dialog
53 else
54 DIALOG=Xdialog
55 fi
56
57 chkdsk=""
58 done=1
59 notraid=1
60 #partprobe >>/dev/null 2>&1
61 #. ./restore2/checkdiffnew2
62 . ./restore2/get_serial_restore
63 . ./restore2/change_names_new
64 . ./restore2/warning
65 . ./restore2/choosedisk
66 . ./unmount-all
67  
68
69 $DIALOG --title "AUTOMATIC ?" --yesno "do you want to automatically restore all disks ? \n (otherwise you will be prompted for each disk)" 30 60 
70
71   if [ $? = 0 ];then
72   echo "" > noprompt
73   fi
74 $DIALOG --title "AUTOMATIC ?" --yesno "do you want to automatically disable \n the check for bad blocks on all disks ? \n (otherwise you will be prompted for each disk)" 30 60 
75
76 if [ $? = 0 ];then
77 echo "" > badblocksnoprompt
78 fi
79
80 ####################################################check raid
81
82                 . ./restore2/checkraid
83
84                 
85                 
86
87
88
89 ######################################## check lvm
90 if [ -f working/scripts/create-vg ];then
91
92 . ./restore2/check_lvm
93 fi
94
95 ####################################################recheck raid
96
97
98                 . ./restore2/checkraid
99
100 #############################################check wether all raid disks have the right partition type
101
102 . ./restore2/all_raids_there
103 ###########################################do all disks
104
105
106 cat disklist|while read line;do
107         disk=`echo $line`
108         . ./restore2/diskorpart
109
110         disk=`echo $disk |cut -d"/" -f3`
111
112    if [ "$partordisk" = "disk" ];then
113   
114   
115    . ./restore2/full_disk
116
117         
118    
119    fi
120
121
122         if [ "$partordisk" = "part" ];then
123                 di=${disk%?}
124                 d=`echo $di |tail -c2`
125                         echo $d | egrep '^[0-9]+$' >/dev/null 2>&1
126                                 if [ "$?" -eq "0" ]; then
127                                 di=${di%?}
128                                 fi
129                 grep $di fulldisks>>/dev/null
130                                         if [ ! $? = 0 ];then
131
132                                         . ./restore2/part
133                                         fi
134         fi
135
136
137 done
138
139
140 if [ -f partitionscript ];then
141 chmod +x partitionscript
142 . ./partitionscript
143 fi
144
145
146 if [ -f checkraidtemp ];then
147 chmod +x checkraidtemp
148 ra=`cat checkraidtemp`
149 if [ ! "$ra" = "" ];then
150 . ./release_raids
151 . ./restore2/raid
152 fi
153 rm checkraidtemp
154 fi
155
156
157
158
159
160
161
162 if [ -f working/scripts/create-vg ];then
163 . ./restore2/do_lvm
164 fi
165 ra=`cat create-vg`
166 if [ ! "$ra" = "" ];then
167 chmod +x create-pv
168 chmod +x create-vg
169 chmod +x create-lv
170
171 . ./create-pv
172 sleep 5
173 . ./create-vg
174 sleep 5
175 . ./create-lv
176 fi
177 $DIALOG --title "Format ?" --yesno "Now we will format the choosen disks, Do you want to do this ?? \n Normally you would answer yes here, \n Only answer No if you want to try to restore them with bacula without formatting them first \n (this could be usefull if you know what's broken on your system \n and you just want bacula to replace certain files) " 600 600 
178
179   if [ $? = 0 ];then
180 chmod +x formatallscript
181
182 . ./formatallscript
183 fi
184 # if [  -d clients/$clientdir.working.bak ];then
185 #mv clients/$clientdir.working.bak clients/$clientdir 
186 #fi
187 . ./chrootscript