X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_PostArchive_Update;h=11de07ee2aa34e57e0c526dc0341df556c2e6e50;hp=aff3a0b85687183a758d2ef6dd5a94055ea6df96;hb=38abb9a20f4f9562df117185570646049ce126fb;hpb=dfc71d1e230596fcb539889fce2a475c45e0acd0 diff --git a/bin/BackupPC_ASA_PostArchive_Update b/bin/BackupPC_ASA_PostArchive_Update index aff3a0b..11de07e 100755 --- a/bin/BackupPC_ASA_PostArchive_Update +++ b/bin/BackupPC_ASA_PostArchive_Update @@ -66,10 +66,7 @@ my $start_t = time(); my $t_fmt = '%Y-%m-%d %H:%M:%S'; -warn "## Conf = ",dump( \%Conf ); - -my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; -my $user = $Conf{SearchUser} || ''; +#warn "## Conf = ",dump( \%Conf ); my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 }); @@ -130,6 +127,14 @@ sub system_ok { system(@_) == 0 || die "system @_:$!"; } +my $sth_inc_size = $dbh->prepare(qq{ + update backups set + inc_size = ?, + parts = ?, + inc_deleted = false + where id = ? +}); + sub check_archive { my ($host,$num) = @_; @@ -171,20 +176,21 @@ sub check_archive { } open(my $gzip, $Conf{GzipPath}." -l $filename |") || die "can't gzip -l $filename: $!"; + local $/ = undef; my $line = <$gzip>; - chomp($line); - $line = <$gzip> if ($line =~ /^\s+compressed/); + close($gzip); my ($comp, $uncomp) = (0,0); - if ($line =~ m/^\s+(\d+)\s+(\d+)\s+\d+\.\d+/) { + if ($line =~ m/\s+(\d+)\s+(\d+)\s+\d+\.\d+/s) { if (wantarray) { return [ $1, $2 ]; } else { return $2; } } else { - die "can't find size in line: $line"; + warn "ERROR can't parse: $line"; + return -s $filename; } } @@ -228,14 +234,14 @@ sub check_archive { print " [parts: ",join(", ", @tar_parts),"]" if $debug; - my $same = 1; my @tar_files; my $backup_part; print " reading" if $debug; - my $part_nr = 1; + my $part_nr = 0; + my $inc_size = 0; foreach my $filename (@tar_parts) { @@ -302,14 +308,20 @@ sub check_archive { my $md5 = $md5sum->{$filename} || die "no md5sum for $filename in ",dump($md5sum); my $items = 1; + $part_nr++; check_part($host, $num, $part_nr, $tar_size, $size, $md5, $items); - $part_nr++; + # round increment size to 2k block size + $inc_size += int(($size + 2048) / 2048); } - # short-cut and exit; - return $same unless($same); + $sth_inc_size->execute( + $inc_size, + $part_nr, + get_backup_id($host, $num), + ); + $dbh->commit; @tar_files = sort @tar_files; print "\n\t",($#tar_files + 1), " tar files"; @@ -335,6 +347,8 @@ sub check_archive { @db_files = sort @db_files; + my $same = 1; + if ($#tar_files != $#db_files) { $same = 0; print " NUMBER";