/[BackupPC]/trunk/bin/BackupPC_checkArchiveConsistency
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/bin/BackupPC_checkArchiveConsistency

Parent Directory Parent Directory | Revision Log Revision Log


Revision 381 - (show annotations)
Thu May 10 06:16:16 2007 UTC (17 years, 1 month ago) by iklaric
File size: 1195 byte(s)
- removeBurnedArchives is tested - removes tgz's that are burned on two or more DVD archives
- checkArchiveConsistency for a given dvd_nr checks all the files that are on that DVD and compares filesize in the database with the one on the filesystem

1 #!/usr/local/bin/perl
2 use strict;
3 no utf8;
4
5 use lib "/data/backuppc-agi//lib";
6 use DBI;
7 use BackupPC::Lib;
8
9 my $bpc = BackupPC::Lib->new || die "can't create BackupPC::Lib";
10 my %Conf = $bpc->Conf();
11
12 my $dsn = $Conf{SearchDSN} || die "need searchdsn in config.pl\n";
13 my $user = $Conf{SearchUser} || '';
14 my $dbh = DBI->connect($dsn, $user, "", { raiseerror => 1, autocommit => 0 });
15 my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir};
16 my $dvd_nr = $ARGV[0];
17
18 if (!defined($dvd_nr)) {
19 print q{
20 No dvd_nr parameter!
21 Usage:
22 $0 <dvd_nr>
23 };
24 exit(0);
25 }
26
27 my $sql = q{
28 SELECT *
29 FROM backups_on_dvds
30 WHERE dvd_nr = ?
31 };
32 my $sth = $dbh->prepare($sql);
33 $sth->execute($dvd_nr);
34 while (my $row = $sth->fetchrow_hashref()) {
35 my $host_share = $row->{share};
36 $host_share =~ s/(.*?):(.*)/$1_$2_/gi;
37 my $filename = $tar_dir."/".$host_share . $row->{num}.".tar.gz";
38 my (undef, undef, undef, undef, undef, undef, undef, $fs_size, undef, undef, undef, undef, undef) = stat($filename);
39 print "checking $filename...";
40 if ($fs_size != $row->{gzip_size}) {
41 print "INVALID: fs_size: $fs_size, db_size: ".$row->{gzip_size}."\n";
42 } else {
43 print "ok\n";
44 }
45
46 }
47 $sth->finish();
48 $dbh->disconnect();
49
50

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26