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.
+---- Changes since 1.510 ----
+Added fields to the scheduled backup page for pre and post backup commands.
$backup = &get_backup($ARGV[0]);
$backup || die "Failed to find backup $ARGV[0]";
+# Run the pre-backup command, if any
+if ($backup->{'pre'}) {
+ $preout = &backquote_command("($backup->{'pre'}) 2>&1 </dev/null");
+ $premsg = &text('email_pre', $backup->{'pre'})."\n".
+ $preout."\n";
+ if ($?) {
+ $err = $text{'email_prefailed'};
+ }
+ }
+
# Do it
@mods = split(/\s+/, $backup->{'mods'});
-$err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
- $backup->{'configfile'}, $backup->{'nofiles'},
- [ split(/\t+/, $backup->{'others'}) ]);
+if (!$err) {
+ $err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
+ $backup->{'configfile'}, $backup->{'nofiles'},
+ [ split(/\t+/, $backup->{'others'}) ]);
+ }
+
+# Run the post-backup command, if any
+if (!$err) {
+ $postout = &backquote_command("($backup->{'post'}) 2>&1 </dev/null");
+ $postmsg = "\n".
+ &text('email_post', $backup->{'post'})."\n".
+ $postout."\n";
+ }
# Send off the results
if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
$nice =~ s/<[^>]+>//g;
$err =~ s/<[^>]+>//g;
if ($err) {
- $msg = $text{'email_mods'}."\n".
+ $msg = $premsg.
+ $text{'email_mods'}."\n".
$mlist.
"\n".
&text('email_failed', $nice)."\n\n".
$subject = &text('email_sfailed', $host);
}
else {
- $msg = $text{'email_mods'}."\n".
+ $msg = $premsg.
+ $text{'email_mods'}."\n".
$mlist.
"\n".
&text('email_ok', $nice)."\n".
- &text('email_final', &nice_size($size))."\n";
+ &text('email_final', &nice_size($size))."\n".
+ $postmsg;
$subject = &text('email_sok', $host);
}
+ print STDERR $msg,"\n";
&mailboxes::send_text_mail($config{'from_addr'} ||
&mailboxes::get_from_address(),
$backup->{'email'},
print &ui_form_start("save.cgi", "post");
print &ui_hidden("new", $in{'new'});
print &ui_hidden("id", $in{'id'});
-print &ui_table_start($text{'edit_header'}, "width=100%", 2);
+
+@tds = ( "width=30%" );
+print &ui_hidden_table_start($text{'edit_header'}, "width=100%", 2,
+ "main", 1, \@tds);
# Show modules to backup
@mods = &list_backup_modules();
$backup->{'nofiles'},
$backup->{'others'}));
+print &ui_hidden_table_end();
+
+print &ui_hidden_table_start($text{'edit_header2'}, "width=100%", 2,
+ "prepost", 0, \@tds);
+
+# Show pre-backup command
+print &ui_table_row($text{'edit_pre'},
+ &ui_textbox("pre", $backup->{'pre'}, 60));
+
+# Show post-backup command
+print &ui_table_row($text{'edit_post'},
+ &ui_textbox("post", $backup->{'post'}, 60));
+
+print &ui_hidden_table_end();
+
+print &ui_hidden_table_start($text{'edit_header3'}, "width=100%", 2,
+ "sched", 0, \@tds);
+
# Show email address
print &ui_table_row($text{'edit_email'},
&ui_textbox("email", $backup->{'email'}, 40));
&ui_radio("sched", $job || $in{'new'} ? 1 : 0,
[ [ 0, $text{'no'} ],
[ 1, $text{'edit_schedyes'} ] ]));
+print &ui_table_row(undef,
+ "<tr> <td colspan=2><table border width=100%>\n".
+ &capture_function_output(\&cron::show_times_input, $backup).
+ "</table></td> </tr>\n");
-print "<tr> <td colspan=2><table border width=100%>\n";
-&cron::show_times_input($backup);
-print "</table></td> </tr>\n";
-
-print &ui_table_end();
+print &ui_hidden_table_end();
if ($in{'new'}) {
print &ui_form_end([ [ 'create', $text{'create'} ] ], "100%");
}
edit_title1=Create Scheduled Backup
edit_title2=Edit Scheduled Backup
edit_header=Scheduled backup options
+edit_header2=Pre and post backup commands
+edit_header3=Backup schedule
edit_email=Email result to address
edit_emode=When to send email
edit_emode0=Always
edit_run=Save and Backup Now
edit_return=backup form
edit_other=Other listed files ..
+edit_pre=Pre-backup command
+edit_post=Post-backup command
save_err=Failed to save backup
save_emods=No modules selected
email_sfailed=Configuration backup on $1 failed
email_sok=Configuration backup on $1 succeeded
email_final=Final backup file size was $1
+email_pre=Running pre-backup command $1 ..
+email_post=Running post-backup command $1 ..
+email_prefailed=Pre-backup command failed!
+
&cron::parse_times_input($backup, \%in);
$backup->{'emode'} = $in{'emode'};
$backup->{'email'} = $in{'email'};
+ $backup->{'pre'} = $in{'pre'};
+ $backup->{'post'} = $in{'post'};
$backup->{'sched'} = $in{'sched'};
($backup->{'configfile'}, $backup->{'nofiles'}, $backup->{'others'}) =
&parse_backup_what("what", \%in);