---- Changes since 1.440 ----
Converted commands in the module's API file to POD format, and added more details about each function.
Backup files are now given 600 permissions, to prevent reading by non-root users.
+---- Changes since 1.490 ----
+Added an option on the restore form to just show the contents of a backup.
return undef;
}
-=head2 execute_restore(&mods, source, &files, apply)
+=head2 execute_restore(&mods, source, &files, apply, [show-only])
Restore configuration files from the specified source for the listed modules.
Returns undef on success, or an error message.
# Call module pre functions
foreach my $m (@{$_[0]}) {
- if ($m && &foreign_check($m)) {
+ if ($m && &foreign_check($m) && !$_[4]) {
&foreign_require($m, "backup_config.pl");
if (&foreign_defined($m, "pre_restore")) {
local $err = &foreign_call($m, "pre_restore", \@files);
}
# Lock all files being extracted
-local $f;
-foreach $f (@files) {
- &lock_file($f);
+if (!$_[4]) {
+ local $f;
+ foreach $f (@files) {
+ &lock_file($f);
+ }
}
# Extract contents (only files specified by manifests)
+local $flag = $_[4] ? "t" : "x";
local $qfiles = join(" ", map { s/^\///; quotemeta($_) }
&unique(@files));
if ($gzipped) {
- &execute_command("cd / ; gunzip -c $qfile | tar xf - $qfiles",
+ &execute_command("cd / ; gunzip -c $qfile | tar ${flag}f - $qfiles",
undef, \$out, \$out);
}
else {
- &execute_command("cd / ; tar xf $qfile $qfiles", undef, \$out, \$out);
+ &execute_command("cd / ; tar ${flag}f $qfile $qfiles",
+ undef, \$out, \$out);
}
local $ex = $?;
# Un-lock all files being extracted
-local $f;
-foreach $f (@files) {
- &unlock_file($f);
+if (!$_[4]) {
+ local $f;
+ foreach $f (@files) {
+ &unlock_file($f);
+ }
}
# Check for tar error
return &text('backup_euntar', "<pre>$out</pre>");
}
-if ($_[3]) {
+if ($_[3] && !$_[4]) {
# Call all module apply functions
foreach $m (@{$_[0]}) {
if (&foreign_defined($m, "post_restore")) {
&show_backup_destination("src", $config{'dest'}, 1));
print &ui_table_row($text{'index_apply'},
- &ui_radio("apply", $config{'apply'} ? 1 : 0,
- [ [ 1, $text{'yes'} ],
- [ 0, $text{'no'} ] ]));
+ &ui_yesno_radio("apply", $config{'apply'} ? 1 : 0));
+
+print &ui_table_row($text{'index_test'},
+ &ui_yesno_radio("test", 0));
print &ui_table_end();
print &ui_form_end([ [ 'restore', $text{'index_now2'} ] ]);
index_header2=Restore configuration now
index_now2=Restore Now
index_apply=Apply configurations?
+index_test=Just show what will be restored?
index_jobs=Scheduled Backups
index_nostrftime=Warning - some backup jobs use % in their filenames, but strftime substitution is not enabled on the Module Config page.
index_tabsched=Scheduled backups
restore_err=Restore failed
restore_title=Restore Configuration
restore_doing=Starting restore of module configuration files from $1 ..
+restore_testing=Extracting contents of backup from $1 ..
restore_failed=.. failed! $1
restore_done=.. complete. $1 files were restored.
+restore_done2=.. files in the backup are :
nice_ftp=$2 on $1 via FTP
nice_ftpp=$2 on $1 port $3 via FTP
$src = $temp;
}
&ui_print_header(undef, $text{'restore_title'}, "");
-print &text('restore_doing', &nice_dest($src)),"<p>\n";
-$err = &execute_restore(\@mods, $src, \@files, $in{'apply'});
+print &text($in{'test'} ? 'restore_testing' : 'restore_doing',
+ &nice_dest($src)),"<p>\n";
+$err = &execute_restore(\@mods, $src, \@files, $in{'apply'}, $in{'test'});
&unlink_file($temp) if ($mode == 3);
if ($err) {
print &text('restore_failed', $err),"<p>\n";
}
+elsif ($in{'test'}) {
+ print $text{'restore_done2'},"<p>\n";
+ print &ui_table_start(undef, "width=100%", 2);
+ print &ui_table_row(undef,
+ "<pre>".join("\n", map { &html_escape($_) } @files)."</pre>", 2);
+ print &ui_table_end();
+ }
else {
print &text('restore_done', scalar(@files)),"<p>\n";
}