version 1.1, 2004/06/17 15:58:42
|
version 1.2, 2004/11/30 12:39:51
|
Line 16 $|=1;
|
Line 16 $|=1;
|
# |
# |
|
|
# program version |
# program version |
my $version = "0.3 (24.9.2003)"; |
my $version = "0.4 (30.11.2004)"; |
|
|
# read command line parameters |
# read command line parameters |
my $args = parseargs; |
my $args = parseargs; |
Line 189 sub fs_read_files {
|
Line 189 sub fs_read_files {
|
|
|
|
|
# |
# |
# $%files = run_query |
# $archcnt = run_query($dirquery, \%files) |
# |
# |
# runs the archiver program on $docdir and returns a list of archived files |
# runs the archiver program on $dirquery and adds to the hash of archived files |
# |
# |
# Sample output: |
# Sample output: |
# 20,345 B 08/06/03 17:17:02 /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839/index.meta Never /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839 |
# 20,345 B 08/06/03 17:17:02 /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839/index.meta Never /mpiwg/archive/data/proyectohumboldt/webb_histo_fr_01_1839 |
# |
# |
sub run_query { |
sub run_query { |
my %files; |
my ($dirquery, $files) = @_; |
print LOG "START checkarchive $version ", scalar localtime, "\n"; |
print LOG "START checkarchive $version ", scalar localtime, "\n"; |
my $archcmd = $archprog; |
my $archcmd = $archprog; |
$archcmd .= " query archive -subdir=yes"; |
$archcmd .= " query archive -subdir=yes"; |
$archcmd .= " -description='$archname'"; |
$archcmd .= " -description='$archname'"; |
$archcmd .= " '$docdir/'"; |
$archcmd .= " '$dirquery'"; |
|
|
my $archcnt = 0; |
my $archcnt = 0; |
print LOG "CMD: $archcmd\n"; |
print LOG "CMD: $archcmd\n"; |
Line 230 sub run_query {
|
Line 230 sub run_query {
|
$date = ymd_date($date); |
$date = ymd_date($date); |
logger("DEBUG", " QUERY: file '$file'"); |
logger("DEBUG", " QUERY: file '$file'"); |
$archcnt++; |
$archcnt++; |
if ($files{$file}) { |
if ($$files{$file}) { |
logger("WARNING", "file $file seems to be archived multiple times: $time $date"); |
logger("DEBUG", "file $file seems to be archived multiple times: $time $date"); |
$warncnt++; |
#$warncnt++; |
|
} |
|
if (length $file <= length $docdir) { |
|
logger("DEBUG", "not below document dir: $file"); |
|
next; |
} |
} |
$files{$file} = [$size, "$date $time"]; |
$$files{$file} = [$size, "$date $time"]; |
} |
} |
} |
} |
logger("INFO", "$archcnt archives of " . (scalar keys %files) . " files."); |
|
} else { |
} else { |
logger("ABORT", "unable to start archive command '$archcmd'!!"); |
logger("ABORT", "unable to start archive command '$archcmd'!!"); |
exit 1; |
exit 1; |
} |
} |
|
|
return \%files; |
return $archcnt; |
} |
} |
|
|
|
|
Line 323 sub compare_files {
|
Line 326 sub compare_files {
|
$errcnt++; |
$errcnt++; |
} |
} |
} else { |
} else { |
logger("ERROR", "file '$ft' on disk missing from archive!"); |
logger("ERROR", "file on disk '$ft' is not in archive!"); |
$errcnt++; |
$errcnt++; |
} |
} |
} |
} |
Line 359 if (-f "$docdir/.archived") {
|
Line 362 if (-f "$docdir/.archived") {
|
} |
} |
|
|
# check archive |
# check archive |
my $archived_files = run_query; |
my %archived_files = (); |
|
my $archcnt = 0; |
|
if ($docdir =~ /\/mpiwg\/archive\/data\/(.*)/) { |
|
# TSM needs two different paths because of historical mount points :-( |
|
my $docdir1 = "/mpiwg/archive/data/"; |
|
$archcnt += run_query($docdir1, \%archived_files); |
|
my $docdir2 = "/mpiwg/archive/"; |
|
$archcnt += run_query($docdir2, \%archived_files); |
|
} else { |
|
$archcnt += run_query("$docdir/", \%archived_files); |
|
} |
|
logger("INFO", "$archcnt archives of " . (scalar keys %archived_files) . " files."); |
|
|
my $num_arch_files = (scalar keys %$archived_files); |
my $num_arch_files = (scalar keys %archived_files); |
if ($num_arch_files == 0) { |
if ($num_arch_files == 0) { |
logger("ABORT", "no archive of this directory!!"); |
logger("ABORT", "no archive of this directory!!"); |
exit 1; |
exit 1; |
Line 369 if ($num_arch_files == 0) {
|
Line 383 if ($num_arch_files == 0) {
|
logger("INFO", "$num_arch_files files archived"); |
logger("INFO", "$num_arch_files files archived"); |
|
|
# check list of archived files |
# check list of archived files |
check_files($files_to_archive, $archived_files); |
check_files($files_to_archive, \%archived_files); |
|
|
# read files from filesystem |
# read files from filesystem |
my %fsfiles; |
my %fsfiles; |
Line 378 my $num_fs_files = fs_read_files($docdir
|
Line 392 my $num_fs_files = fs_read_files($docdir
|
|
|
logger("INFO", "$num_fs_files files still on disk!"); |
logger("INFO", "$num_fs_files files still on disk!"); |
if ($num_fs_files > 0) { |
if ($num_fs_files > 0) { |
compare_files(\%fsfiles, $archived_files); |
compare_files(\%fsfiles, \%archived_files); |
} |
} |
|
|
logger("INFO", "$warncnt warnings"); |
logger("INFO", "$warncnt warnings"); |
logger("INFO", "$errcnt errors"); |
logger("INFO", "$errcnt errors"); |
if ($errcnt == 0) { |
if ($errcnt == 0) { |
logger("DONE", "" . (scalar keys %$archived_files) . " archived files checked"); |
logger("DONE", "" . (scalar keys %archived_files) . " archived files OK"); |
} else { |
} else { |
logger("ABORT", "there were $errcnt errors!!"); |
logger("ABORT", "there were $errcnt errors!!"); |
exit 1; |
exit 1; |