3 # supported_filesystems()
4 # Returns a list of filesystem types on which dumping is supported
5 sub supported_filesystems
8 push(@rv, "ufs") if (&has_command("ufsdump"));
12 # multiple_directory_support(fs)
13 # Returns 1 if some filesystem dump supports multiple directories
14 sub multiple_directory_support
16 return $_[0] eq "ufs";
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 local ($dump, $tds) = @_;
38 print &ui_table_row(&hlink($text{'dump_update'},"update"),
39 &ui_yesno_radio("update", int($_[0]->{'update'})),
42 print &ui_table_row(&hlink($text{'dump_verify'},"verify"),
43 &ui_yesno_radio("verify", int($_[0]->{'verify'})),
46 print &ui_table_row(&hlink($text{'dump_level'},"level"),
47 &ui_select("level", int($_[0]->{'level'}),
48 [ map { [ $_, $text{'dump_level_'.$_} ] }
49 (0 .. 9) ]), 1, $tds);
51 print &ui_table_row(&hlink($text{'dump_offline'},"offline"),
52 &ui_yesno_radio("offline", int($_[0]->{'offline'})),
59 # Parse common options
60 if ($in{'mode'} == 0) {
61 $in{'file'} =~ /\S/ || &error($text{'dump_efile'});
62 $_[0]->{'file'} = $in{'file'};
63 delete($_[0]->{'host'});
64 delete($_[0]->{'huser'});
65 delete($_[0]->{'hfile'});
68 &to_ipaddress($in{'host'}) ||
69 &to_ip6address($in{'host'}) ||
70 &error($text{'dump_ehost'});
71 $_[0]->{'host'} = $in{'host'};
72 $in{'huser'} =~ /^\S+$/ || &error($text{'dump_ehuser'});
73 $_[0]->{'huser'} = $in{'huser'};
74 $in{'hfile'} || &error($text{'dump_ehfile'});
75 $_[0]->{'hfile'} = $in{'hfile'};
76 delete($_[0]->{'file'});
79 $_[0]->{'update'} = $in{'update'};
80 $_[0]->{'verify'} = $in{'verify'};
81 $_[0]->{'level'} = $in{'level'};
82 $_[0]->{'offline'} = $in{'offline'};
85 # execute_dump(&dump, filehandle, escape, background-mode, [time])
86 # Executes a dump and displays the output
90 local $cmd = "ufsdump $_[0]->{'level'}";
91 $cmd .= "u" if ($_[0]->{'update'});
92 $cmd .= "v" if ($_[0]->{'verify'});
93 $cmd .= "o" if ($_[0]->{'offline'});
94 if ($_[0]->{'huser'}) {
95 $cmd .= "f '$_[0]->{'huser'}\@$_[0]->{'host'}:".
96 &date_subs($_[0]->{'hfile'}, $_[4])."'";
98 elsif ($_[0]->{'host'}) {
99 $cmd .= "f '$_[0]->{'host'}:".&date_subs($_[0]->{'hfile'}, $_[4])."'";
102 $cmd .= "f '".&date_subs($_[0]->{'file'}, $_[4])."'";
104 $cmd .= " $_[0]->{'extra'}" if ($_[0]->{'extra'});
105 local @dirs = $_[0]->{'tabs'} ? split(/\t+/, $_[0]->{'dir'})
106 : split(/\s+/, $_[0]->{'dir'});
107 $cmd .= " ".join(" ", map { "'$_'" } @dirs);
109 &system_logged("sync");
111 &additional_log('exec', undef, $cmd);
112 &open_execute_command(CMD, "$cmd 2>&1 </dev/null", 1);
115 print $fh &html_escape($_);
128 if ($_[0]->{'file'}) {
129 return "<tt>".&html_escape($_[0]->{'file'})."</tt>";
131 elsif ($_[0]->{'huser'}) {
132 return "<tt>".&html_escape("$_[0]->{'huser'}\@$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
135 return "<tt>".&html_escape("$_[0]->{'host'}:$_[0]->{'hfile'}")."</tt>";
139 # missing_restore_command(filesystem)
140 sub missing_restore_command
142 return &has_command("ufsrestore") ? undef : "ufsrestore";
145 # restore_form(filesystem)
149 print &ui_table_row(&hlink($text{'restore_src'}, "rsrc"),
150 &ui_radio("mode", $_[1]->{'host'} ? 1 : 0,
151 [ [ 0, $text{'dump_file'}." ".
152 &ui_textbox("file", $_[1]->{'file'}, 50).
153 " ".&file_chooser_button("file")."<br>" ],
154 [ 1, &text('dump_host',
155 &ui_textbox("host", $_[1]->{'host'}, 15),
156 &ui_textbox("huser", $_[1]->{'huser'}, 8),
157 &ui_textbox("hfile", $_[1]->{'hfile'}, 20)) ] ]), 3, $tds);
160 print &ui_table_row(&hlink($text{'restore_files'},"rfiles"),
161 &ui_opt_textbox("files", undef, 40, $text{'restore_all'},
162 $text{'restore_sel'}), 3, $tds);
165 print &ui_table_row(&hlink($text{'restore_dir'},"rdir"),
166 &ui_textbox("dir", undef, 50)." ".
167 &file_chooser_button("dir", 1), 3, $tds);
170 print &ui_table_row(&hlink($text{'restore_test'},"rtest"),
171 &ui_yesno_radio("test", 1), 1, $tds);
174 # parse_restore(filesystem)
175 # Parses inputs from restore_form() and returns a command to be passed to
181 $cmd .= ($in{'test'} ? " t" : " x");
182 if ($in{'mode'} == 0) {
183 $in{'file'} || &error($text{'restore_efile'});
184 $cmd .= "f '$in{'file'}'";
187 &to_ipaddress($in{'host'}) ||
188 &to_ip6address($in{'host'}) ||
189 &error($text{'restore_ehost'});
190 $in{'huser'} =~ /^\S*$/ || &error($text{'restore_ehuser'});
191 $in{'hfile'} || &error($text{'restore_ehfile'});
193 $cmd .= "f '$in{'huser'}\@$in{'host'}:$in{'hfile'}'";
196 $cmd .= "f '$in{'host'}:$in{'hfile'}'";
200 $cmd .= " $in{'extra'}" if ($in{'extra'});
201 if (!$in{'files_def'}) {
202 $in{'files'} || &error($text{'restore_efiles'});
203 $cmd .= " $in{'files'}";
205 -d $in{'dir'} || &error($text{'restore_edir'});
210 # restore_backup(filesystem, command)
211 # Restores a backup based on inputs from restore_form(), and displays the results
214 &additional_log('exec', undef, $_[1]);
216 &foreign_require("proc", "proc-lib.pl");
217 local ($fh, $fpid) = &foreign_call("proc", "pty_process_exec", "cd '$in{'dir'}' ; $_[1]");
220 local $rv = &wait_for($fh, "(next volume #)", "(set owner.mode for.*\\[yn\\])", "(Directories already exist, set modes anyway. \\[yn\\])", "((.*)\\[yn\\])", "(.*\\n)");
222 print &html_escape($matches[1]);
225 return $text{'restore_evolume'};
228 syswrite($fh, "1\n", 2);
231 elsif ($rv == 1 || $rv == 2) {
232 syswrite($fh, "n\n", 2);
235 return &text('restore_equestion',
236 "<tt>$matches[2]</tt>");