X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Famcheckdump.pl;h=e277e24b9290e00c8ec8f03efbdbc3f9d878be0f;hb=refs%2Fheads%2Fupstream;hp=d8042bc9294d0f62df571419fb4fea096c6f0c6c;hpb=cd0b924f27312d57bd42f6c4fae2b795139e2d0b;p=debian%2Famanda diff --git a/server-src/amcheckdump.pl b/server-src/amcheckdump.pl index d8042bc..e277e24 100644 --- a/server-src/amcheckdump.pl +++ b/server-src/amcheckdump.pl @@ -1,9 +1,10 @@ #! @PERL@ -# Copyright (c) 2007, 2008, 2009, 2010 Zmanda, Inc. All Rights Reserved. +# Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. # -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 as published -# by the Free Software Foundation. +# 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 the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY @@ -70,8 +71,10 @@ my $opt_timestamp; my $opt_verbose = 0; my $config_overrides = new_config_overrides($#ARGV+1); +debug("Arguments: " . join(' ', @ARGV)); Getopt::Long::Configure(qw(bundling)); GetOptions( + 'version' => \&Amanda::Util::version_opt, 'timestamp|t=s' => \$opt_timestamp, 'verbose|v' => \$opt_verbose, 'help|usage|?' => \&usage, @@ -220,7 +223,7 @@ sub find_validation_command { "TAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ], "GTAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ], "GNUTAR" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ], - "SMBCLIENT" => [ $Amanda::Constants::GNUTAR, qw(--ignore-zeros -tf -) ], + "SMBCLIENT" => [ $Amanda::Constants::GNUTAR, qw(-tf -) ], "PKZIP" => undef, ); if (!exists $validation_programs{$program}) { @@ -259,7 +262,9 @@ sub main { my $all_success = 1; my @xfer_errs; my %all_filter; - my $check_done; + my $current_dump; + my $recovery_done; + my %recovery_params; my $steps = define_steps cb_ref => \$finished_cb, @@ -338,6 +343,10 @@ sub main { step check_dumpfile => sub { my ($dump) = @_; + $current_dump = $dump; + + $recovery_done = 0; + %recovery_params = (); print "Validating image " . $dump->{hostname} . ":" . $dump->{diskname} . " dumped " . $dump->{dump_timestamp} . " level ". @@ -434,8 +443,8 @@ sub main { delete $all_filter{$src}; $src->remove(); POSIX::close($fd); - if (!%all_filter and $check_done) { - $finished_cb->(); + if (!%all_filter and $recovery_done) { + $steps->{'filter_done'}->(); } } else { $buffer .= $b; @@ -451,7 +460,7 @@ sub main { } my $xfer = Amanda::Xfer->new([ $xfer_src, @filters, $xfer_dest ]); - $xfer->start($steps->{'handle_xmsg'}); + $xfer->start($steps->{'handle_xmsg'}, 0, $current_dump->{'bytes'}); $clerk->start_recovery( xfer => $xfer, recovery_cb => $steps->{'recovery_cb'}); @@ -469,12 +478,17 @@ sub main { }; step recovery_cb => sub { - my %params = @_; + %recovery_params = @_; + $recovery_done = 1; + + $steps->{'filter_done'}->() if !%all_filter; + }; + step filter_done => sub { # distinguish device errors from validation errors - if (@{$params{'errors'}}) { + if (@{$recovery_params{'errors'}}) { print STDERR "While reading from volumes:\n"; - print STDERR "$_\n" for @{$params{'errors'}}; + print STDERR "$_\n" for @{$recovery_params{'errors'}}; return $steps->{'quit'}->("validation aborted"); } @@ -498,27 +512,20 @@ sub main { if ($err) { $exit_code = 1; print STDERR $err, "\n"; - return $clerk->quit(finished_cb => $steps->{'quit1'}) if defined $clerk;; - return $steps->{'quit1'}->(); + return $clerk->quit(finished_cb => $finished_cb) if defined $clerk; + return $finished_cb->(); } if ($all_success) { print "All images successfully validated\n"; } else { - print "Some images failed to be correclty validated.\n"; + print "Some images failed to be correctly validated.\n"; $exit_code = 1; } - return $clerk->quit(finished_cb => $steps->{'quit1'}); + return $clerk->quit(finished_cb => $finished_cb); }; - step quit1 => sub { - $check_done = 1; - - if (!%all_filter) { - $finished_cb->(); - } - } } main(sub { Amanda::MainLoop::quit(); });