#
# -m Do monthly aging of per-PC log files and sending of email.
# Otherise, BackupPC_nightly just does pool pruning.
+# Since several BackupPC_nightly processes might run
+# concurrently, just the first one is given the -m flag
+# by BackupPC.
#
# The poolRangeStart and poolRangeEnd arguments are integers from 0 to 255.
# These specify which parts of the pool to process. There are 256 2nd-level
#
#========================================================================
#
-# Version 2.1.0beta1, released 9 Apr 2004.
+# Version 3.0.0alpha, released 23 Jan 2006.
#
# See http://backuppc.sourceforge.net.
#
my $fileRepMax; # worse case number of files that have repeated checksums
# (ie: max(nnn+1) for all names xxxxxxxxxxxxxxxx_nnn)
my $fileLinkMax; # maximum number of hardlinks on a pool file
+my $fileLinkTotal; # total number of hardlinks on entire pool
my $fileCntRename; # number of renamed files (to keep file numbering
# contiguous)
my %FixList; # list of paths that need to be renamed to avoid
$fileLinkMax = 0;
$fileCntRename = 0;
%FixList = ();
- find({wanted => \&GetPoolStats}, "$TopDir/$pool/$dir");
+ find({wanted => \&GetPoolStats}, "$TopDir/$pool/$dir")
+ if ( -d "$TopDir/$pool/$dir" );
my $kb = $blkCnt / 2;
my $kbRm = $blkCntRm / 2;
my $kb2 = $blkCnt2 / 2;
}
print("BackupPC_stats $i = $pool,$fileCnt,$dirCnt,$kb,$kb2,$kbRm,"
. "$fileCntRm,$fileCntRep,$fileRepMax,"
- . "$fileCntRename,$fileLinkMax\n");
+ . "$fileCntRename,$fileLinkMax,$fileLinkTotal\n");
}
}
printf("BackupPC_nightly lock_off\n");
###########################################################################
-# Send email
+# Send email and generation of backupInfo files for each backup
###########################################################################
if ( $opts{m} ) {
print("log BackupPC_nightly now running BackupPC_sendEmail\n");
- system("$BinDir/BackupPC_sendEmail")
+ system("$BinDir/BackupPC_sendEmail");
+ doBackupInfoUpdate();
}
#
}
}
+#
+# Update the backupInfo files based on the backups file.
+# We do this just once a week (on Sun) since it is only
+# needed for old backups with BackupPC <= 2.1.2.
+#
+sub doBackupInfoUpdate
+{
+ my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
+ return if ( $wday != 0 );
+
+ foreach my $host ( sort(keys(%{$bpc->HostInfoRead()})) ) {
+ my @Backups = $bpc->BackupInfoRead($host);
+
+ for ( my $i = 0 ; $i < @Backups ; $i++ ) {
+ #
+ # BackupPC::Storage->backupInfoWrite won't overwrite
+ # an existing file
+ #
+ BackupPC::Storage->backupInfoWrite("$TopDir/pc/$host",
+ $Backups[$i]{num},
+ $Backups[$i]);
+ }
+ }
+}
+
sub GetPoolStats
{
my($nlinks, $nblocks) = (lstat($_))[3, 12];
$blkCnt += $nblocks;
$blkCnt2 += $nblocks if ( $nlinks == 2 );
$fileLinkMax = $nlinks if ( $fileLinkMax < $nlinks );
+ $fileLinkTotal += $nlinks - 1;
}
}