+
+ #
+ # Queue multiple nightly jobs based on the configuration
+ #
+ $Conf{MaxBackupPCNightlyJobs} = 1
+ if ( $Conf{MaxBackupPCNightlyJobs} <= 0 );
+ $Conf{BackupPCNightlyPeriod} = 1
+ if ( $Conf{BackupPCNightlyPeriod} <= 0 );
+ #
+ # Decide what subset of the 16 top-level directories 0..9a..f
+ # we run BackupPC_nightly on, based on $Conf{BackupPCNightlyPeriod}.
+ # If $Conf{BackupPCNightlyPeriod} == 1 then we run 0..15 every
+ # time. If $Conf{BackupPCNightlyPeriod} == 2 then we run
+ # 0..7 one night and 89a-f the next night. And so on.
+ #
+ # $Info{NightlyPhase} counts which night, from 0 to
+ # $Conf{BackupPCNightlyPeriod} - 1.
+ #
+ my $start = int($Info{NightlyPhase} * 16
+ / $Conf{BackupPCNightlyPeriod});
+ my $end = int(($Info{NightlyPhase} + 1) * 16
+ / $Conf{BackupPCNightlyPeriod});
+ $end = $start + 1 if ( $end <= $start );
+ $Info{NightlyPhase}++;
+ $Info{NightlyPhase} = 0 if ( $end >= 16 );
+
+ #
+ # Zero out the data we expect to get from BackupPC_nightly.
+ # In the future if we want to split BackupPC_nightly over
+ # more than one night we will only zero out the portion
+ # that we are running right now.
+ #
+ for my $p ( qw(pool cpool) ) {
+ for ( my $i = $start ; $i < $end ; $i++ ) {
+ $Info{pool}{$p}[$i]{FileCnt} = 0;
+ $Info{pool}{$p}[$i]{DirCnt} = 0;
+ $Info{pool}{$p}[$i]{Kb} = 0;
+ $Info{pool}{$p}[$i]{Kb2} = 0;
+ $Info{pool}{$p}[$i]{KbRm} = 0;
+ $Info{pool}{$p}[$i]{FileCntRm} = 0;
+ $Info{pool}{$p}[$i]{FileCntRep} = 0;
+ $Info{pool}{$p}[$i]{FileRepMax} = 0;
+ $Info{pool}{$p}[$i]{FileCntRename} = 0;
+ $Info{pool}{$p}[$i]{FileLinkMax} = 0;
+ $Info{pool}{$p}[$i]{Time} = 0;
+ }
+ }
+ print(LOG $bpc->timeStamp,
+ sprintf("Running %d BackupPC_nightly jobs from %d..%d"
+ . " (out of 0..15)\n",
+ $Conf{MaxBackupPCNightlyJobs}, $start, $end - 1));
+
+ #
+ # Now queue the $Conf{MaxBackupPCNightlyJobs} jobs.
+ # The granularity on start and end is now 0..256.
+ #
+ $start *= 16;
+ $end *= 16;
+ my $start0 = $start;
+ for ( my $i = 0 ; $i < $Conf{MaxBackupPCNightlyJobs} ; $i++ ) {
+ #
+ # The first nightly job gets the -m option (does email, log aging).
+ # All jobs get the start and end options from 0..255 telling
+ # them which parts of the pool to traverse.
+ #
+ my $cmd = ["$BinDir/BackupPC_nightly"];
+ push(@$cmd, "-m") if ( $i == 0 );
+ push(@$cmd, $start);
+ $start = $start0 + int(($end - $start0)
+ * ($i + 1) / $Conf{MaxBackupPCNightlyJobs});
+ push(@$cmd, $start - 1);
+
+ my $job = $bpc->adminJob($i);
+ unshift(@CmdQueue, {
+ host => $job,
+ user => "BackupPC",
+ reqTime => time,
+ cmd => $cmd,
+ });
+ $CmdQueueOn{$job} = 1;
+ }
+ $RunNightlyWhenIdle = 2;
+