X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_fixupBackupSummary;h=c5402dc58ef7624438605014bccdf9d9cd35059d;hp=537bbc1e1f17b73ba4c2be52c554ba33aab94e77;hb=488bb662f6d144d42376b3d14e9b1e438e00e6f8;hpb=27f513f89d885d24bf1a01242fba676c7a840fd5 diff --git a/bin/BackupPC_fixupBackupSummary b/bin/BackupPC_fixupBackupSummary index 537bbc1..c5402dc 100755 --- a/bin/BackupPC_fixupBackupSummary +++ b/bin/BackupPC_fixupBackupSummary @@ -1,4 +1,4 @@ -#!/bin/perl +#!/usr/bin/perl #============================================================= -*-perl-*- # # BackupPC_fixupBackupSummary: recreate backups file in case @@ -12,7 +12,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2005 Craig Barratt +# Copyright (C) 2005-2009 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ # #======================================================================== # -# Version 3.0.0alpha, released 23 Jan 2006. +# Version 3.2.0, released 31 Jul 2010. # # See http://backuppc.sourceforge.net. # @@ -56,6 +56,17 @@ my $Hosts = $bpc->HostInfoRead(); my @hostList; our(%backupInfo); +my %opts; + +if ( !getopts("l", \%opts) ) { + print STDERR <BackupInfoRead($host); - # - # Temporary: create backupInfo files in each backup - # directory - # - foreach ( my $i = 0 ; $i < @Backups ; $i++ ) { - BackupPC::Storage->backupInfoWrite($dir, $Backups[$i]{num}, - $Backups[$i]); - if ( 0 ) { - my $bkupNum = $Backups[$i]{num}; - if ( !-f "$dir/$bkupNum/backupInfo" ) { - my($dump) = Data::Dumper->new( - [ $Backups[$i]], - [qw(*backupInfo)]); - $dump->Indent(1); - if ( open(BKUPINFO, ">", "$dir/$bkupNum/backupInfo") ) { - print(BKUPINFO $dump->Dump); - close(BKUPINFO); - } - } - } - } - # # Look through the LOG files to get information about # completed backups. The data from the LOG file is @@ -121,7 +110,7 @@ foreach my $host ( @hostList ) { my @files = readdir(DIR); closedir(DIR); foreach my $file ( @files ) { - if ( $file =~ /^LOG(.\d+\.z)?/ ) { + if ( $opts{l} && $file =~ /^LOG(.\d+\.z)?/ ) { push(@LogFiles, $file); } elsif ( $file =~ /^(\d+)$/ ) { my $bkupNum = $1; @@ -154,6 +143,7 @@ foreach my $host ( @hostList ) { # @LogFiles = sort({-M "$dir/$a" <=> -M "$dir/$b"} @LogFiles); my $startTime; + my $fillFromNum; foreach my $file ( @LogFiles ) { my $f = BackupPC::FileZIO->open("$dir/$file", 0, $file =~ /\.z/); @@ -163,13 +153,12 @@ foreach my $host ( @hostList ) { } print(" Reading $file\n"); while ( (my $str = $f->readLine()) ne "" ) { - if ( $str =~ /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (full|incr|partial) backup started for directory / ) { - $startTime = $str; + if ( $str =~ /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (full|incr|partial) backup started / ) { + $startTime = parsedate($1); next; } next if ( $str !~ /^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (full|incr|partial) backup (\d+) complete, (\d+) files, (\d+) bytes, (\d+) xferErrs \((\d+) bad files, (\d+) bad shares, (\d+) other\)/ ); - my $endTime = $1; my $type = $2; my $bkupNum = $3; my $nFilesTotal = $4; @@ -177,13 +166,14 @@ foreach my $host ( @hostList ) { my $xferErrs = $6; my $badFiles = $7; my $badShare = $8; + my $endTime = parsedate($1); print(" Got $type backup $bkupNum at $endTime\n"); - next if ( !-d "$dir/$2" ); + next if ( !-d "$dir/$bkupNum" ); $BkupFromLOG->{$bkupNum} = { num => $bkupNum, type => $type, - startTime => parsedate($startTime), - endTime => parsedate($endTime), + startTime => $startTime, + endTime => $endTime, size => $sizeTotal, nFiles => $nFilesTotal, xferErrs => $xferErrs, @@ -197,14 +187,12 @@ foreach my $host ( @hostList ) { noFill => $type eq "incr" ? 1 : 0, level => $type eq "incr" ? 1 : 0, mangle => 1, - noFill => $noFill; - fillFromNum => $fillFromNum; + fillFromNum => $fillFromNum, }; + $fillFromNum = $bkupNum if ( $type eq "full" ); } } - splice(@Backups, 2, 1); - # # Now merge any info from $BkupFromInfo and $BkupFromLOG # that is missing from @Backups. @@ -244,7 +232,8 @@ foreach my $host ( @hostList ) { if ( $changes ) { @Backups = sort({$a->{num} <=> $b->{num}} @Backups); - print Dumper \@Backups; + # print Dumper \@Backups; + $bpc->BackupInfoWrite($host, @Backups); } else { print(" No changes for host $host\n"); }