mirror of
https://github.com/webmin/webmin.git
synced 2025-08-19 01:15:14 +00:00
Pre and post backup commands
This commit is contained in:
@ -9,11 +9,31 @@ require './backup-config-lib.pl';
|
||||
$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'}) {
|
||||
@ -26,7 +46,8 @@ 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".
|
||||
@ -34,13 +55,16 @@ if (($err || $backup->{'emode'} == 0) && $backup->{'email'}) {
|
||||
$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'},
|
||||
|
Reference in New Issue
Block a user