Support Level= and Pool= tags on schedules

This commit is contained in:
Jamie Cameron
2007-09-26 19:00:20 +00:00
parent 5d9a713f11
commit 4785dc66ea
5 changed files with 40 additions and 7 deletions

View File

@@ -3,3 +3,5 @@ First version of this module, which allows Bacula to be configured and both back
---- Changes since 1.360 ----
Removed the requirement for the /etc/bacula/bacula command to be installed, if /etc/init.d/bacula-* scripts exist.
Added a field to the mount/un-mount page for entering an auto-loader slot number.
---- Changes since 1.370 ----
Backup schedules with Level= and Pool= tags are now properly displayed and editable.

View File

@@ -1532,5 +1532,22 @@ if ($str =~ /^(\d{4})\-(\d\d)\-(\d\d)\s+(\d\d):(\d\d):(\d\d)$/) {
return undef;
}
# extract_schedule(run)
# Given a schedule Run string like Level=Full Pool=Monthly 1st sat at 03:05,
# returns a hash ref of the tags and the schedule.
sub extract_schedule
{
local ($run) = @_;
local $tags;
while($run =~ s/^(\S+)=(\S+)\s+//) {
$tags{$1} = $2;
}
if (!$tags{'Level'}) {
$run =~ s/^(\S+)\s+//;
$tags{'Level'} = $1;
}
return ( \%tags, $run );
}
1;

View File

@@ -29,20 +29,31 @@ print &ui_table_row($text{'schedule_name'},
# Run files
@runs = &find_value("Run", $schedule->{'members'});
@pools = &find("Pool", $conf);
&sort_by_name(\@pools);
$rtable = &ui_columns_start([ $text{'schedule_level'},
$text{'schedule_pool'},
$text{'schedule_times'} ], "width=100%");
$i = 0;
foreach $r (@runs, undef, undef, undef) {
($level, $times) = split(/\s+/, $r, 2);
$level =~ s/^Level\s*=\s*//;
$sched = &parse_schedule($times);
# Parse out the level and pool
$tags = { };
if ($r) {
($tags, $r) = &extract_schedule($r);
}
$sched = &parse_schedule($r);
$rtable .= &ui_columns_row([
&ui_select("level_$i", $level,
&ui_select("level_$i", $tags->{'Level'},
[ [ "", " " ], [ "Full" ],
[ "Incremental" ], [ "Differential" ] ],
1, 0, 1),
&ui_textbox("times_$i", $times,
$sched || !$r ? "40 readonly" : 40)." ".
&ui_select("pool_$i", $tags->{'Pool'},
[ [ "", "<$text{'default'}>" ],
map { my $pn = &find_value("Name",
$_->{'members'}); [ $pn ] } @pools ],
1, 0, 1),
&ui_textbox("times_$i", $r, 50, 0, undef,
$sched || !$r ? "readonly" : "")." ".
&schedule_chooser_button("times_$i") ]);
$i++;
}

View File

@@ -172,6 +172,7 @@ schedule_header=Backup schedule details
schedule_name=Backup schedule name
schedule_runs=Run levels and times
schedule_level=Backup level
schedule_pool=Volume
schedule_times=Run at times
schedule_err=Failed to save backup schedule
schedule_ename=Missing or invalid schedule name

View File

@@ -40,7 +40,9 @@ else {
next if (!$level);
$times = $in{"times_$i"};
$times =~ /\S/ || &error(&text('schedule_etimes', $i+1));
push(@runs, "$level $times");
push(@runs, "Level=$level ".
($in{"pool_$i"} ? "Pool=".$in{"pool_$i"}." " : "").
$times);
}
&save_directives($conf, $schedule, "Run", \@runs, 1);