mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Run pre and post backup commands for scheduled backups run manually.
https://sourceforge.net/tracker/index.php?func=detail&aid=3207620&group_id=17457&atid=117457#
This commit is contained in:
@@ -20,3 +20,5 @@ Backup files are now given 600 permissions, to prevent reading by non-root users
|
|||||||
Added an option on the restore form to just show the contents of a backup.
|
Added an option on the restore form to just show the contents of a backup.
|
||||||
---- Changes since 1.510 ----
|
---- Changes since 1.510 ----
|
||||||
Added fields to the scheduled backup page for pre and post backup commands.
|
Added fields to the scheduled backup page for pre and post backup commands.
|
||||||
|
---- Changes since 1.530 ----
|
||||||
|
When a scheduled backup is run manually, and pre and post commands are now also run.
|
||||||
|
|||||||
@@ -67,12 +67,29 @@ else {
|
|||||||
if ($in{'run'}) {
|
if ($in{'run'}) {
|
||||||
# Execute the backup now
|
# Execute the backup now
|
||||||
&ui_print_unbuffered_header(undef, $text{'run_title'}, "");
|
&ui_print_unbuffered_header(undef, $text{'run_title'}, "");
|
||||||
|
|
||||||
|
# Run the pre-backup command, if any
|
||||||
|
if ($backup->{'pre'} =~ /\S/) {
|
||||||
|
$preout = &backquote_command(
|
||||||
|
"($backup->{'pre'}) 2>&1 </dev/null");
|
||||||
|
print &text('email_pre',
|
||||||
|
"<tt>".&html_escape($backup->{'pre'})."</tt>")."<br>\n".
|
||||||
|
"<pre>".&html_escape($preout)."</pre>\n";
|
||||||
|
if ($?) {
|
||||||
|
$err = $text{'email_prefailed'};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@mods = split(/\s+/, $backup->{'mods'});
|
@mods = split(/\s+/, $backup->{'mods'});
|
||||||
$nice = &nice_dest($backup->{'dest'}, 1);
|
$nice = &nice_dest($backup->{'dest'}, 1);
|
||||||
print &text('run_doing', scalar(@mods), "<tt>$nice</tt>"),"<br>\n";
|
if (!$err) {
|
||||||
$err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef,
|
print &text('run_doing', scalar(@mods),
|
||||||
$backup->{'configfile'}, $backup->{'nofiles'},
|
"<tt>$nice</tt>"),"<br>\n";
|
||||||
[ split(/\t+/, $backup->{'others'}) ]);
|
$err = &execute_backup(
|
||||||
|
\@mods, $backup->{'dest'}, \$size, undef,
|
||||||
|
$backup->{'configfile'}, $backup->{'nofiles'},
|
||||||
|
[ split(/\t+/, $backup->{'others'}) ]);
|
||||||
|
}
|
||||||
if ($err) {
|
if ($err) {
|
||||||
print "<pre>$err</pre>";
|
print "<pre>$err</pre>";
|
||||||
print "$text{'run_failed'}<p>\n";
|
print "$text{'run_failed'}<p>\n";
|
||||||
@@ -80,6 +97,16 @@ if ($in{'run'}) {
|
|||||||
else {
|
else {
|
||||||
print "$text{'run_ok'}<p>\n";
|
print "$text{'run_ok'}<p>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run the post-backup command, if any
|
||||||
|
if (!$err && $backup->{'post'} =~ /\S/) {
|
||||||
|
$postout = &backquote_command(
|
||||||
|
"($backup->{'post'}) 2>&1 </dev/null");
|
||||||
|
print &text('email_post',
|
||||||
|
"<tt>".&html_escape($backup->{'post'})."</tt>")."<br>\n".
|
||||||
|
"<pre>".&html_escape($postout)."</pre>\n";
|
||||||
|
}
|
||||||
|
|
||||||
&webmin_log("run", "backup", $backup->{'dest'}, $backup);
|
&webmin_log("run", "backup", $backup->{'dest'}, $backup);
|
||||||
&ui_print_footer("edit.cgi?id=$in{'id'}", $text{'edit_return'},
|
&ui_print_footer("edit.cgi?id=$in{'id'}", $text{'edit_return'},
|
||||||
"index.cgi?mode=sched", $text{'index_return'});
|
"index.cgi?mode=sched", $text{'index_return'});
|
||||||
|
|||||||
Reference in New Issue
Block a user