use strict;
use warnings;
-package main::Interactive;
+package main::Interactivity;
use POSIX qw( :errno_h );
use Amanda::MainLoop qw( :GIOCondition );
use vars qw( @ISA );
-@ISA = qw( Amanda::Interactive );
+@ISA = qw( Amanda::Interactivity );
sub new {
my $class = shift;
if (!defined $n_read) {
return if ($! == EINTR);
$self->abort();
- return $params{'finished_cb'}->(
+ return $params{'request_cb'}->(
Amanda::Changer::Error->new('fatal',
message => "Fail to read from stdin"));
} elsif ($n_read == 0) {
$self->abort();
- return $params{'finished_cb'}->(
+ return $params{'request_cb'}->(
Amanda::Changer::Error->new('fatal',
message => "Aborted by user"));
} else {
chomp $line;
$buffer = "";
$self->abort();
- return $params{'finished_cb'}->(undef, $line);
+ return $params{'request_cb'}->(undef, $line);
}
}
};
package Amvault;
use Amanda::Config qw( :getconf config_dir_relative );
-use Amanda::Debug qw( :logging );
+use Amanda::Debug qw( :logging debug );
use Amanda::Xfer qw( :constants );
use Amanda::Header qw( :constants );
use Amanda::MainLoop;
use Amanda::Cmdline;
use Amanda::Paths;
use Amanda::Logfile qw( :logtype_t log_add log_add_full
- log_rename $amanda_log_trace_log make_stats
- match_datestamp match_level );
+ log_rename $amanda_log_trace_log make_stats );
+use Amanda::Util qw ( match_datestamp match_level );
use base qw(
Amanda::Recovery::Clerk::Feedback
exporting => 0, # is an export in progress?
call_after_export => undef, # call this when export complete
+ config_overrides_opts => $params{'config_overrides_opts'},
# called when the operation is complete, with the exit
# status
my $src = $self->{'src'} = {};
# put together a clerk, which of course requires a changer, scan,
- # interactive, and feedback
+ # interactivity, and feedback
my $chg = Amanda::Changer->new();
return $self->failure("Error opening source changer: $chg")
if $chg->isa('Amanda::Changer::Error');
$src->{'seen_labels'} = {};
- $src->{'interactive'} = main::Interactive->new();
+ $src->{'interactivity'} = main::Interactivity->new();
$src->{'scan'} = Amanda::Recovery::Scan->new(
chg => $src->{'chg'},
- interactive => $src->{'interactive'});
+ interactivity => $src->{'interactivity'});
$src->{'clerk'} = Amanda::Recovery::Clerk->new(
changer => $src->{'chg'},
$dump->{'dump_timestamp'} . " " .
$dump->{'level'} . "\n";
}
- $total_kb += $dump->{'kb'};
+ $total_kb += int $dump->{'kb'};
}
print STDOUT "Total Size: $total_kb KB\n";
sub setup_dst {
my $self = shift;
my $dst = $self->{'dst'} = {};
+ my $tlf = Amanda::Config::config_dir_relative(getconf($CNF_TAPELIST));
+ my $tl = Amanda::Tapelist->new($tlf);
$dst->{'label'} = undef;
$dst->{'tape_num'} = 0;
- my $chg = Amanda::Changer->new($self->{'dst_changer'});
+ my $chg = Amanda::Changer->new($self->{'dst_changer'},
+ tapelist => $tl,
+ labelstr => getconf($CNF_LABELSTR),
+ autolabel => $self->{'dst_autolabel'});
return $self->failure("Error opening destination changer: $chg")
if $chg->isa('Amanda::Changer::Error');
$dst->{'chg'} = $chg;
+ my $interactivity = Amanda::Interactivity->new(
+ name => getconf($CNF_INTERACTIVITY));
+ my $scan_name = getconf($CNF_TAPERSCAN);
$dst->{'scan'} = Amanda::Taper::Scan->new(
+ algorithm => $scan_name,
changer => $dst->{'chg'},
+ interactivity => $interactivity,
+ tapelist => $tl,
labelstr => getconf($CNF_LABELSTR),
autolabel => $self->{'dst_autolabel'});
# create and start the transfer
$xfer = Amanda::Xfer->new([ $xfer_src, $xfer_dst ]);
- $xfer->start($steps->{'handle_xmsg'});
+ my $size = 0;
+ $size = $current->{'dump'}->{'bytes'} if exists $current->{'dump'}->{'bytes'};
+ $xfer->start($steps->{'handle_xmsg'}, 0, $size);
# count the "threads" running here (clerk and scribe)
$n_threads = 2;
my $steps = define_steps
cb_ref => \$exit_cb;
+ # the export may not start until we quit the scribe, so wait for it now..
+ step check_exporting => sub {
+ # if we're exporting the final volume, wait for that to complete
+ if ($self->{'exporting'}) {
+ $self->{'call_after_export'} = $steps->{'quit_scribe'};
+ } else {
+ $steps->{'quit_scribe'}->();
+ }
+ };
+
# we may have several resources to clean up..
step quit_scribe => sub {
if ($self->{'cleanup'}{'quit_scribe'}) {
$self->{'dst'}{'scribe'}->quit(
finished_cb => $steps->{'quit_scribe_finished'});
} else {
- $steps->{'check_exporting'}->();
+ $steps->{'quit_clerk'}->();
}
};
step quit_scribe_finished => sub {
+ $self->{'dst'}{'scan'}->quit();
my ($err) = @_;
if ($err) {
print STDERR "$err\n";
$exit_status = 1;
}
- $steps->{'check_exporting'}->();
- };
-
- # the export may not start until we quit the scribe, so wait for it now..
- step check_exporting => sub {
- # if we're exporting the final volume, wait for that to complete
- if ($self->{'exporting'}) {
- $self->{'call_after_export'} = $steps->{'quit_clerk'};
- } else {
- $steps->{'quit_clerk'}->();
- }
+ $steps->{'quit_clerk'}->();
};
step quit_clerk => sub {
};
step roll_log => sub {
+ if (defined $self->{'src'}->{'chg'}) {
+ $self->{'src'}->{'chg'}->quit();
+ $self->{'src'}->{'chg'} = undef;
+ }
+ if (defined $self->{'dst'}->{'chg'}) {
+ $self->{'dst'}->{'chg'}->quit();
+ $self->{'dst'}->{'chg'} = undef;
+ }
if ($self->{'cleanup'}{'roll_trace_log'}) {
log_add_full($L_FINISH, "driver", "fake driver finish");
log_add($L_INFO, "pid-done $$");
- debug("invoking amreport..");
- system("$sbindir/amreport", $self->{'config_name'}, "--from-amdump");
+ my @amreport_cmd = ("$sbindir/amreport", $self->{'config_name'}, "--from-amdump",
+ @{$self->{'config_overrides_opts'}});
+ debug("invoking amreport (" . join(" ", @amreport_cmd) . ")");
+ system(@amreport_cmd);
debug("rolling logfile..");
log_rename($self->{'dst_write_timestamp'});
my $self = shift;
my %params = @_;
+ debug("$params{'message'}");
log_add_full($L_INFO, "taper", $params{'message'});
}
# exports are going on simultaneously.
$self->{'exporting'}++;
- my $finished_cb = sub {};
+ my $finished_cb = $params{'finished_cb'};
my $steps = define_steps
cb_ref => \$finished_cb;
Amanda::Util::setup_application("amvault", "server", $CONTEXT_CMDLINE);
my $config_overrides = new_config_overrides($#ARGV+1);
+my @config_overrides_opts;
my $opt_quiet = 0;
my $opt_dry_run = 0;
my $opt_fulls_only = 0;
usage("unknown --autolabel value '$val'");
}
+debug("Arguments: " . join(' ', @ARGV));
Getopt::Long::Configure(qw{ bundling });
GetOptions(
- 'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
+ 'o=s' => sub {
+ push @config_overrides_opts, "-o" . $_[1];
+ add_config_override_opt($config_overrides, $_[1]);
+ },
'q|quiet' => \$opt_quiet,
'n|dry-run' => \$opt_dry_run,
'fulls-only' => \$opt_fulls_only,
opt_dry_run => $opt_dry_run,
quiet => $opt_quiet,
fulls_only => $opt_fulls_only,
- opt_export => $opt_export);
+ opt_export => $opt_export,
+ config_overrides_opts => \@config_overrides_opts);
Amanda::MainLoop::call_later(sub { $vault->run($exit_cb) });
Amanda::MainLoop::run();