3 # supported_filesystems()
4 # Returns a list of filesystem types on which dumping is supported
5 sub supported_filesystems
8 push(@rv, "xfs") if (&has_command("xfsdump"));
12 # multiple_directory_support(fs)
13 # Returns 1 if some filesystem dump supports multiple directories
14 sub multiple_directory_support
22 # Display destination options
23 print &ui_table_row(&hlink($text{'dump_dest'}, "dest"),
24 &ui_radio("mode", $_[0]->{'host'} ? 1 : 0,
25 [ [ 0, $text{'dump_file'}." ".
26 &ui_textbox("file", $_[0]->{'file'}, 50).
27 " ".&file_chooser_button("file")."<br>" ],
28 [ 1, &text('dump_host',
29 &ui_textbox("host", $_[0]->{'host'}, 15),
30 &ui_textbox("huser", $_[0]->{'huser'}, 8),
31 &ui_textbox("hfile", $_[0]->{'hfile'}, 20)) ] ]), 3);
36 # Display xfs dump options
37 print &ui_table_row(&hlink($text{'dump_level'},"level"),
38 &ui_select("level", int($_[0]->{'level'}),
39 [ map { [ $_, $text{'dump_level_'.$_} ] }
40 (0 .. 9) ]), 1, $tds);
42 print &ui_table_row(&hlink($text{'dump_label'},"label"),
43 &ui_textbox("label", $_[0]->{'label'}, 15),
46 print &ui_table_row(&hlink($text{'dump_max'},"max"),
47 &ui_opt_textbox("max", $_[0]->{'max'}, 8,
48 $text{'dump_unlimited'})." kB", 1, $tds);
50 print &ui_table_row(&hlink($text{'dump_attribs'},"attribs"),
51 &ui_yesno_radio("attribs", int($_[0]->{'attribs'})),
54 print &ui_table_row(&hlink($text{'dump_over'},"over"),
55 &ui_yesno_radio("over", int($_[0]->{'over'})),
58 print &ui_table_row(&hlink($text{'dump_invent'},"invent"),
59 &ui_radio("noinvent", int($_[0]->{'noinvent'}),
60 [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ] ]),
63 print &ui_table_row(&hlink($text{'dump_overwrite'},"overwrite"),
64 &ui_yesno_radio("overwrite", int($_[0]->{'overwrite'})),
67 print &ui_table_row(&hlink($text{'dump_erase'},"erase"),
68 &ui_yesno_radio("erase", int($_[0]->{'erase'})),
75 # Parse common options
76 if ($in{'mode'} == 0) {
77 $in{'file'} =~ /\S/ || &error($text{'dump_efile'});
78 $_[0]->{'file'} = $in{'file'};
79 delete($_[0]->{'host'});
80 delete($_[0]->{'huser'});
81 delete($_[0]->{'hfile'});
84 &to_ipaddress($in{'host'}) ||
85 &to_ip6address($in{'host'}) ||
86 &error($text{'dump_ehost'});
87 $_[0]->{'host'} = $in{'host'};
88 $in{'huser'} =~ /^\S+$/ || &error($text{'dump_ehuser'});
89 $_[0]->{'huser'} = $in{'huser'};
90 $in{'hfile'} || &error($text{'dump_ehfile'});
91 $_[0]->{'hfile'} = $in{'hfile'};
92 delete($_[0]->{'file'});
96 &is_mount_point($in{'dir'}) || &error($text{'dump_emp'});
97 $in{'label'} =~ /^\S*$/ && length($in{'label'}) < 256 ||
98 &error($text{'dump_elabel2'});
99 $_[0]->{'label'} = $in{'label'};
100 $_[0]->{'level'} = $in{'level'};
101 if ($in{'max_def'}) {
102 delete($_[0]->{'max'});
105 $in{'max'} =~ /^\d+$/ || &error($text{'dump_emax'});
106 $_[0]->{'max'} = $in{'max'};
108 $_[0]->{'noattribs'} = $in{'noattribs'};
109 $_[0]->{'over'} = $in{'over'};
110 $_[0]->{'noinvent'} = $in{'noinvent'};
111 $_[0]->{'overwrite'} = $in{'overwrite'};
112 $_[0]->{'erase'} = $in{'erase'};
115 # execute_dump(&dump, filehandle, escape, background-mode, [time])
116 # Executes a dump and displays the output
121 if ($_[0]->{'huser'}) {
122 $flag = " -f '$_[0]->{'huser'}\@$_[0]->{'host'}:".
123 &date_subs($_[0]->{'hfile'}, $_[4])."'";
125 elsif ($_[0]->{'host'}) {
126 $flag = " -f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'}, $_[4])."'";
129 $flag = " -f '".&date_subs($_[0]->{'file'}, $_[4])."'";
131 $cmd = "xfsdump -l $_[0]->{'level'}";
133 $cmd .= " -L '$_[0]->{'label'}'" if ($_[0]->{'label'});
134 $cmd .= " -M '$_[0]->{'label'}'" if ($_[0]->{'label'});
135 $cmd .= " -z '$_[0]->{'max'}'" if ($_[0]->{'max'});
136 $cmd .= " -A" if ($_[0]->{'noattribs'});
137 $cmd .= " -F" if ($_[0]->{'over'});
138 $cmd .= " -J" if ($_[0]->{'noinvent'});
139 $cmd .= " -o" if ($_[0]->{'overwrite'});
140 $cmd .= " -c \"$_[3] $_[0]->{'id'}\"" if ($_[3]);
141 $cmd .= " -E -F" if ($_[0]->{'erase'});
142 $cmd .= " $_[0]->{'extra'}" if ($_[0]->{'extra'});
143 $cmd .= " '$_[0]->{'dir'}'";
145 &system_logged("sync");
147 &additional_log('exec', undef, $cmd);
148 &open_execute_command(CMD, "$cmd 2>&1 </dev/null", 1);
151 print $fh &html_escape($_);
164 if ($_[0]->{'file'}) {
165 return "<tt>".&html_escape($_[0]->{'file'})."</tt>";
167 elsif ($_[0]->{'huser'}) {
168 return "<tt>".&html_escape("$_[0]->{'huser'}\@$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
171 return "<tt>".&html_escape("$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
175 # missing_restore_command(filesystem)
176 sub missing_restore_command
178 local $cmd = $_[0] eq 'xfs' ? 'xfsrestore' : 'restore';
179 return &has_command($cmd) ? undef : $cmd;
182 # restore_form(filesystem)
186 print &ui_table_row(&hlink($text{'restore_src'}, "rsrc"),
187 &ui_radio("mode", $_[1]->{'host'} ? 1 : 0,
188 [ [ 0, $text{'dump_file'}." ".
189 &ui_textbox("file", $_[1]->{'file'}, 50).
190 " ".&file_chooser_button("file")."<br>" ],
191 [ 1, &text('dump_host',
192 &ui_textbox("host", $_[1]->{'host'}, 15),
193 &ui_textbox("huser", $_[1]->{'huser'}, 8),
194 &ui_textbox("hfile", $_[1]->{'hfile'}, 20)) ] ]), 3, $tds);
197 print &ui_table_row(&hlink($text{'restore_dir'},"rdir"),
198 &ui_textbox("dir", undef, 50)." ".
199 &file_chooser_button("dir", 1), 3, $tds);
202 print &ui_table_row(&hlink($text{'restore_over'},"rover"),
203 &ui_radio("over", 0, [ [ 0, $text{'restore_over0'} ],
204 [ 1, $text{'restore_over1'} ],
205 [ 2, $text{'restore_over2'} ] ]), 3, $tds);
208 print &ui_table_row(&hlink($text{'restore_noattribs'},"rnoattribs"),
209 &ui_radio("noattribs", 0, [ [ 0, $text{'yes'} ],
210 [ 1, $text{'no'} ] ]), 1, $tds);
212 # Label to restore from
213 print &ui_table_row(&hlink($text{'restore_label'},"rlabel"),
214 &ui_textbox("label", undef, 20), 1, $tds);
217 print &ui_table_row(&hlink($text{'restore_test'},"rtest"),
218 &ui_yesno_radio("test", 1), 1, $tds);
221 # parse_restore(filesystem)
222 # Parses inputs from restore_form() and returns a command to be passed to
226 local $cmd = "xfsrestore";
227 $cmd .= " -t" if ($in{'test'});
228 if ($in{'mode'} == 0) {
229 $in{'file'} || &error($text{'restore_efile'});
230 $cmd .= " -f '$in{'file'}'";
233 &to_ipaddress($in{'host'}) ||
234 &to_ip6address($in{'host'}) ||
235 &error($text{'restore_ehost'});
236 $in{'huser'} =~ /^\S*$/ || &error($text{'restore_ehuser'});
237 $in{'hfile'} || &error($text{'restore_ehfile'});
239 $cmd .= " -f '$in{'huser'}\@$in{'host'}:$in{'hfile'}'";
242 $cmd .= " -f '$in{'host'}:$in{'hfile'}'";
245 $cmd .= " -E" if ($in{'over'} == 1);
246 $cmd .= " -e" if ($in{'over'} == 2);
247 $cmd .= " -A" if ($in{'noattribs'});
248 $cmd .= " -L '$in{'label'}'" if ($in{'label'});
250 $cmd .= " $in{'extra'}" if ($in{'extra'});
252 -d $in{'dir'} || &error($text{'restore_edir'});
253 $cmd .= " '$in{'dir'}'";
258 # restore_backup(filesystem, command)
259 # Restores a backup based on inputs from restore_form(), and displays the results
262 &additional_log('exec', undef, $_[1]);
263 if ($_[0] eq 'xfs') {
264 # Just run the backup command
265 &open_execute_command(CMD, "$_[1] 2>&1 </dev/null", 1);
267 print &html_escape($_);
273 # Need to supply prompts
274 &foreign_require("proc", "proc-lib.pl");
275 local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", "cd '$in{'dir'}' ; $_[1]");
278 local $rv = &wait_for($fh, "(next volume #)", "(set owner.mode for.*\\[yn\\])", "((.*)\\[yn\\])", "(.*\\n)");
280 print &html_escape($matches[1]);
283 return $text{'restore_evolume'};
286 syswrite($fh, "1\n", 2);
290 syswrite($fh, "n\n", 2);
293 return &text('restore_equestion',
294 "<tt>$matches[2]</tt>");