App-BackupPlan
view release on metacpan or search on metacpan
lib/App/BackupPlan.pm view on Meta::CPAN
package App::BackupPlan;
use 5.012003;
use strict;
use warnings;
use Config;
use DateTime;
use Time::Local;
use XML::DOM;
use Log::Log4perl qw(:easy);
use App::BackupPlan::Policy;
use App::BackupPlan::Utils qw(fromISO2TS fromTS2ISO addSpan subSpan);
require XML::DOM;
require Log::Log4perl;
require Exporter;
use AutoLoader qw(AUTOLOAD);
our @ISA = qw(Exporter);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use App::BackupPlan ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
BEGIN {
our $VERSION = '0.0.11';
print "App::BackupPlan by codimoc, version $VERSION\n";
}
# Preloaded methods go here.
our $TAR = 'system'; #use system tar
our $HAS_EXCLUDE_TAG = 0; #has tar option --exclude-tag
sub new {
my $class = shift;
my $self = {
config => shift,
log => shift
};
bless $self,$class;
return $self;
}
sub run_policy {
my ($policy,$now, $logger) = @_;
$policy->print;
$logger->debug($policy->info) if defined $logger;
my $ts = &fromTS2ISO($now);
my %files = &getFiles($policy->getTargetDir,$policy->getPrefix);
#get last
my $lastts = &getLastTs(keys %files);
my $threshold = &fromTS2ISO(&subSpan($now,$policy->getFrequency));
( run in 0.491 second using v1.01-cache-2.11-cpan-39bf76dae61 )