From: Dobrica Pavlinusic Date: Tue, 4 Jan 2011 15:37:21 +0000 (+0000) Subject: check filesize of archives on disk with size in database X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=ad8b6832fb9669c60644fd7d0a7d294828f6931c check filesize of archives on disk with size in database --- diff --git a/bin/BackupPC_checkArchiveConsistency b/bin/BackupPC_checkArchiveConsistency new file mode 100755 index 0000000..2a9b629 --- /dev/null +++ b/bin/BackupPC_checkArchiveConsistency @@ -0,0 +1,50 @@ +#!/usr/local/bin/perl +use strict; +no utf8; + +use lib "/data/backuppc-agi//lib"; +use DBI; +use BackupPC::Lib; + +my $bpc = BackupPC::Lib->new || die "can't create BackupPC::Lib"; +my %Conf = $bpc->Conf(); + +my $dsn = $Conf{SearchDSN} || die "need searchdsn in config.pl\n"; +my $user = $Conf{SearchUser} || ''; +my $dbh = DBI->connect($dsn, $user, "", { raiseerror => 1, autocommit => 0 }); +my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}; +my $dvd_nr = $ARGV[0]; + +if (!defined($dvd_nr)) { + print q{ + No dvd_nr parameter! + Usage: + $0 + }; + exit(0); +} + +my $sql = q{ + SELECT * + FROM backups_on_dvds + WHERE dvd_nr = ? +}; +my $sth = $dbh->prepare($sql); +$sth->execute($dvd_nr); +while (my $row = $sth->fetchrow_hashref()) { + my $host_share = $row->{share}; + $host_share =~ s/(.*?):(.*)/$1_$2_/gi; + my $filename = $tar_dir."/".$host_share . $row->{num}.".tar.gz"; + my (undef, undef, undef, undef, undef, undef, undef, $fs_size, undef, undef, undef, undef, undef) = stat($filename); + print "checking $filename..."; + if ($fs_size != $row->{gzip_size}) { + print "INVALID: fs_size: $fs_size, db_size: ".$row->{gzip_size}."\n"; + } else { + print "ok\n"; + } + +} +$sth->finish(); +$dbh->disconnect(); + +