1#! @PERL@ 2# Copyright (c) 2010-2013 Zmanda Inc. All Rights Reserved. 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License 6# as published by the Free Software Foundation; either version 2 7# of the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, but 10# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12# for more details. 13# 14# You should have received a copy of the GNU General Public License along 15# with this program; if not, write to the Free Software Foundation, Inc., 16# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17# 18# Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300 19# Sunnyvale, CA 94086, USA, or: http://www.zmanda.com 20 21use lib '@amperldir@'; 22use strict; 23use warnings; 24 25use Amanda::Util qw( :constants ); 26use Amanda::Config qw( :init ); 27use Amanda::Logfile qw( log_rename get_current_log_timestamp $amanda_log_trace_log ); 28use Amanda::Debug qw( debug ); 29use Getopt::Long; 30 31Amanda::Util::setup_application("amlogroll", "server", $CONTEXT_CMDLINE); 32 33my $config_overrides = new_config_overrides($#ARGV+1); 34 35debug("Arguments: " . join(' ', @ARGV)); 36Getopt::Long::Configure(qw{bundling}); 37GetOptions( 38 'version' => \&Amanda::Util::version_opt, 39 'o=s' => sub { add_config_override_opt($config_overrides, $_[1]); }, 40) or usage(); 41 42if (@ARGV < 1) { 43 die "USAGE: amlogroll <config> <config-overwrites> <ignored-stuff>"; 44} 45 46set_config_overrides($config_overrides); 47config_init($CONFIG_INIT_EXPLICIT_NAME, $ARGV[0]); 48my ($cfgerr_level, @cfgerr_errors) = config_errors(); 49if ($cfgerr_level >= $CFGERR_WARNINGS) { 50 config_print_errors(); 51 if ($cfgerr_level >= $CFGERR_ERRORS) { 52 die "Errors processing config file"; 53 } 54} 55 56# our STDERR may be connected to the amdump log file, so be sure to do unbuffered 57# writes to that file 58my $old_fh = select(STDERR); 59$| = 1; 60select($old_fh); 61 62Amanda::Debug::add_amanda_log_handler($amanda_log_trace_log); 63 64Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER); 65 66# the actual work of the program - very short! 67my $timestamp = get_current_log_timestamp(); 68die "could not get current timestamp" unless $timestamp; 69log_rename($timestamp); 70 71Amanda::Util::finish_application(); 72