use lib '@amperldir@';
use strict;
+use warnings;
use Getopt::Long;
use Amanda::Config qw( :init :getconf config_dir_relative );
use Amanda::Paths;
use Amanda::Constants;
use Amanda::Process;
-
+use Amanda::Logfile;
+use Amanda::Holding;
+use Amanda::Debug qw( debug );
my $kill_enable=0;
my $process_alive=0;
my $verbose=0;
+my $clean_holding=0;
sub usage() {
- print "Usage: amcleanup [-k] [-v] [-p] conf\n";
+ print "Usage: amcleanup [-k] [-v] [-p] [-r] conf\n";
exit 1;
}
my $config_overrides = new_config_overrides($#ARGV+1);
+debug("Arguments: " . join(' ', @ARGV));
Getopt::Long::Configure(qw(bundling));
GetOptions(
+ 'version' => \&Amanda::Util::version_opt,
'k' => \$kill_enable,
'p' => \$process_alive,
'v' => \$verbose,
+ 'r' => \$clean_holding,
'help|usage' => \&usage,
'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); },
) or usage();
my $logdir=config_dir_relative(getconf($CNF_LOGDIR));
my $logfile = "$logdir/log";
my $amreport="$sbindir/amreport";
-my $amlogroll="$amlibexecdir/amlogroll";
my $amtrmidx="$amlibexecdir/amtrmidx";
-my $amcleanupdisk="$amlibexecdir/amcleanupdisk";
+my $amcleanupdisk="$sbindir/amcleanupdisk";
if ( ! -e "$CONFIG_DIR/$config_name" ) {
die "Configuration directory '$CONFIG_DIR/$config_name' doesn't exist\n";
if (-f $logfile) {
Amanda::Debug::debug("Processing log file");
run_system(0, $amreport, $config_name, "--from-amdump");
- run_system(1, $amlogroll, $config_name);
+
+ my $ts = Amanda::Logfile::get_current_log_timestamp();
+ Amanda::Logfile::log_rename($ts);
+
run_system(1, $amtrmidx, $config_name);
} else {
print "amcleanup: no unprocessed logfile to clean up.\n";
}
}
-if ($verbose) {
- system $amcleanupdisk, "-v", $config_name;
-} else {
- system $amcleanupdisk, $config_name;
-}
+my @amcleanupdisk;
+push @amcleanupdisk, $amcleanupdisk;
+push @amcleanupdisk, "-v" if $verbose;
+push @amcleanupdisk, "-r" if $clean_holding;
+push @amcleanupdisk, $config_name;
+system @amcleanupdisk;
Amanda::Util::finish_application();