From efc2a2c5cdfb76ab756de4217fd076e15b051456 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 12 Mar 2011 10:21:58 -0800 Subject: [PATCH] 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# --- backup-config/CHANGELOG | 2 ++ backup-config/save.cgi | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/backup-config/CHANGELOG b/backup-config/CHANGELOG index bed36ce3b..927a688cc 100644 --- a/backup-config/CHANGELOG +++ b/backup-config/CHANGELOG @@ -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. ---- Changes since 1.510 ---- 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. diff --git a/backup-config/save.cgi b/backup-config/save.cgi index e1d360234..1c7044003 100755 --- a/backup-config/save.cgi +++ b/backup-config/save.cgi @@ -67,12 +67,29 @@ else { if ($in{'run'}) { # Execute the backup now &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 ".&html_escape($backup->{'pre'})."")."
\n". + "
".&html_escape($preout)."
\n"; + if ($?) { + $err = $text{'email_prefailed'}; + } + } + @mods = split(/\s+/, $backup->{'mods'}); $nice = &nice_dest($backup->{'dest'}, 1); - print &text('run_doing', scalar(@mods), "$nice"),"
\n"; - $err = &execute_backup(\@mods, $backup->{'dest'}, \$size, undef, - $backup->{'configfile'}, $backup->{'nofiles'}, - [ split(/\t+/, $backup->{'others'}) ]); + if (!$err) { + print &text('run_doing', scalar(@mods), + "$nice"),"
\n"; + $err = &execute_backup( + \@mods, $backup->{'dest'}, \$size, undef, + $backup->{'configfile'}, $backup->{'nofiles'}, + [ split(/\t+/, $backup->{'others'}) ]); + } if ($err) { print "
$err
"; print "$text{'run_failed'}

\n"; @@ -80,6 +97,16 @@ if ($in{'run'}) { else { print "$text{'run_ok'}

\n"; } + + # Run the post-backup command, if any + if (!$err && $backup->{'post'} =~ /\S/) { + $postout = &backquote_command( + "($backup->{'post'}) 2>&1 ".&html_escape($backup->{'post'})."")."
\n". + "

".&html_escape($postout)."
\n"; + } + &webmin_log("run", "backup", $backup->{'dest'}, $backup); &ui_print_footer("edit.cgi?id=$in{'id'}", $text{'edit_return'}, "index.cgi?mode=sched", $text{'index_return'});