misc updates... largely done and just working on adding a script now for misc stuff
This commit is contained in:
parent
6771971557
commit
2539991daa
|
@ -11,6 +11,7 @@ WriteMakefile(
|
|||
LICENSE => 'artistic_2',
|
||||
PL_FILES => {},
|
||||
MIN_PERL_VERSION => '5.006',
|
||||
INST_SCRIPT => 'bin',
|
||||
CONFIGURE_REQUIRES => {
|
||||
'ExtUtils::MakeMaker' => '0',
|
||||
},
|
||||
|
@ -18,8 +19,7 @@ WriteMakefile(
|
|||
'Test::More' => '0',
|
||||
},
|
||||
PREREQ_PM => {
|
||||
#'ABC' => '1.6',
|
||||
#'Foo::Bar::Module' => '5.0401',
|
||||
"Error::Helper"=>'1.0.0',
|
||||
},
|
||||
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
|
||||
clean => { FILES => 'BackupPC-Backups-Info-*' },
|
||||
|
|
|
@ -118,7 +118,7 @@ sub get_dir{
|
|||
|
||||
=head2 get_last
|
||||
|
||||
Gets the last line parsed for a
|
||||
Gets the last line parsed for a for the file.
|
||||
|
||||
If the machine has not been parsed yet, it will be and the last
|
||||
entry returned.
|
||||
|
@ -129,9 +129,10 @@ The first is the machine in question.
|
|||
|
||||
The second is perl boolean if it should reread the file even if it already has a last.
|
||||
|
||||
The BACKUP HASH for information on the returned hash reference.
|
||||
|
||||
my $lastRef=$bpcinfo->get_last($machine)
|
||||
if ( $self->error ){
|
||||
if ( $bpcinfo->error ){
|
||||
warn('something happened'.$self->errorstring);
|
||||
}
|
||||
|
||||
|
@ -159,11 +160,10 @@ sub get_last{
|
|||
$self->warn;
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
if (
|
||||
(!defined( $self->{last}{ $machine } )) ||
|
||||
$forced
|
||||
$force
|
||||
){
|
||||
$self->get_parsed( $machine );
|
||||
if ( $self->error ){
|
||||
|
@ -181,6 +181,9 @@ This returns the directory which will contain the directories for the hosts setu
|
|||
There is no need for error checking as long as it did not error upon init.
|
||||
|
||||
my $dir=$bpcinfo->get_dir;
|
||||
if ( $bpcinfo->error ){
|
||||
warn('something happened'.$self->errorstring);
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -197,9 +200,15 @@ sub get_pc_dir{
|
|||
=head2 get_parsed
|
||||
|
||||
This parses the raw backups file and then returns a array of hashes.
|
||||
For a explanation of the hashes, please see BACKUP HASH.
|
||||
|
||||
One archment is taken and that is the machine name.
|
||||
|
||||
my @parsed=$bpcinfo->get_parsed($machine);
|
||||
if ( $bpcinfo->error ){
|
||||
warn('something happened: '.$self->errorstring);
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub get_parsed{
|
||||
|
@ -246,6 +255,10 @@ sub get_parsed{
|
|||
$backup{sizeExistComp}, $backup{sizeNewComp}, $backup{noFill},
|
||||
$backup{fillFromNum}, $backup{mangle}, $backup{xferMethod}, $backup{level} )=split(/\t/, $lines[$int]);
|
||||
|
||||
if ( $backup{compress} eq ''){
|
||||
$backup{compress}=0;
|
||||
}
|
||||
|
||||
push( @parsed, \%backup );
|
||||
|
||||
$int++;
|
||||
|
@ -272,7 +285,7 @@ is suggested reading if you plan on actually using this.
|
|||
my $raw=$bpcinfo->get_raw('foo');
|
||||
if ($bpcinfo->error){
|
||||
warn('something errored');
|
||||
}
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -327,7 +340,12 @@ sub get_raw{
|
|||
|
||||
=head2 list_machines
|
||||
|
||||
This returns an array of machines backed up via
|
||||
This returns an array of machines backed up.
|
||||
|
||||
my @machines=$bpcinfo->list_machines;
|
||||
if ( $bpcinfo->error ){
|
||||
warn('something happened: '.$self->errorstring);
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
|
@ -360,10 +378,40 @@ sub list_machines{
|
|||
return @machines;
|
||||
}
|
||||
|
||||
=head2 list_parsed
|
||||
|
||||
This returns a array the machines that have currently been parsed.
|
||||
|
||||
As long as no permanent errors are set, this will not error.
|
||||
|
||||
my @parsed=$bpcinfo->list_parsed;
|
||||
|
||||
=cut
|
||||
|
||||
sub list_parsed{
|
||||
my $self=$_[0];
|
||||
|
||||
if( ! $self->errorblank ){
|
||||
return undef;
|
||||
}
|
||||
|
||||
return keys(%{$self->{parsed}});
|
||||
}
|
||||
|
||||
=head2 read_in_all
|
||||
|
||||
This reads in the backups files for each machine.
|
||||
|
||||
Currently this just attempts to read in all via get_parsed
|
||||
and ignores any errors, just proceeding to the next one.
|
||||
|
||||
As long as list_machines does not error, this will not error.
|
||||
|
||||
$bpcinfo->read_in_all
|
||||
if ( $bpcinfo->error ){
|
||||
warn('something happened: '.$self->errorstring);
|
||||
}
|
||||
|
||||
=cut
|
||||
|
||||
sub read_in_all{
|
||||
|
@ -392,6 +440,102 @@ sub read_in_all{
|
|||
return 1;
|
||||
}
|
||||
|
||||
=head1 BACKUP HASH
|
||||
|
||||
Based on __TOPDIR__/pc/$host/backup from
|
||||
L<https://backuppc.github.io/backuppc/BackupPC.html#Storage-layout>.
|
||||
|
||||
=head2 num
|
||||
|
||||
The backup number for the current hash.
|
||||
|
||||
=head2 type
|
||||
|
||||
Either 'incr' or 'full'.
|
||||
|
||||
=head2 startTime
|
||||
|
||||
The unix start time of the backup.
|
||||
|
||||
=head2 endTime
|
||||
|
||||
The unix end time of the backup.
|
||||
|
||||
=head2 nFiles
|
||||
|
||||
Number of files backed up.
|
||||
|
||||
=head2 size
|
||||
|
||||
Total file size backed up.
|
||||
|
||||
=head2 nFilesExist
|
||||
|
||||
Number of files already in the pool.
|
||||
|
||||
=head2 sizeExist
|
||||
|
||||
Total size of files that were already in the pool.
|
||||
|
||||
=head2 nFilesNew
|
||||
|
||||
Number of new files not already in the pool.
|
||||
|
||||
=head2 sizeNew
|
||||
|
||||
Total size of files not in the pool.
|
||||
|
||||
=head2 xferErrs
|
||||
|
||||
Number of warnings/errors from the backup method.
|
||||
|
||||
=head2 xferBadFile
|
||||
|
||||
Number of errors from the backup method in regards to bad files.
|
||||
|
||||
=head2 xferBadShare
|
||||
|
||||
Number of errors from smbclient that were bad share errors.
|
||||
|
||||
=head2 tarErrs
|
||||
|
||||
Number of errors from BackupPC_tarExtract.
|
||||
|
||||
=head2 compress
|
||||
|
||||
The compression level used on this backup. Zero means no compression.
|
||||
|
||||
Please note that while BackupPC may leave this field blank if none is used, this module
|
||||
will check for a blank value and set it to zero.
|
||||
|
||||
=head2 sizeExistComp
|
||||
|
||||
Total compressed size of files that already existed in the pool.
|
||||
|
||||
=head2 sizeNewComp
|
||||
|
||||
Total compressed size of new files in the pool.
|
||||
|
||||
=head2 noFill
|
||||
|
||||
et if this backup has not been filled in with the most recent previous filled or full backup.
|
||||
See $Conf{IncrFill} in the BackupPC docs.
|
||||
|
||||
=head2 fillFromNum
|
||||
|
||||
If filled, this is the backup it was filled from.
|
||||
|
||||
=head2 mangle
|
||||
|
||||
Set if this backup has mangled file names and attributes. Always true for backups in v1.4.0
|
||||
and above. False for all backups prior to v1.4.0.
|
||||
|
||||
=head2 xferMethod
|
||||
|
||||
The value of $Conf{XferMethod} when this dump was done.
|
||||
|
||||
=head2 level
|
||||
|
||||
=head1 ERROR FLAGS
|
||||
|
||||
=head2 1/backBackupPCdig
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
#!perl -T
|
||||
use 5.006;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
|
||||
plan tests => 3;
|
||||
|
||||
sub not_in_file_ok {
|
||||
my ($filename, %regex) = @_;
|
||||
open( my $fh, '<', $filename )
|
||||
or die "couldn't open $filename for reading: $!";
|
||||
|
||||
my %violated;
|
||||
|
||||
while (my $line = <$fh>) {
|
||||
while (my ($desc, $regex) = each %regex) {
|
||||
if ($line =~ $regex) {
|
||||
push @{$violated{$desc}||=[]}, $.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (%violated) {
|
||||
fail("$filename contains boilerplate text");
|
||||
diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
|
||||
} else {
|
||||
pass("$filename contains no boilerplate text");
|
||||
}
|
||||
}
|
||||
|
||||
sub module_boilerplate_ok {
|
||||
my ($module) = @_;
|
||||
not_in_file_ok($module =>
|
||||
'the great new $MODULENAME' => qr/ - The great new /,
|
||||
'boilerplate description' => qr/Quick summary of what the module/,
|
||||
'stub function definition' => qr/function[12]/,
|
||||
);
|
||||
}
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Need to replace the boilerplate text";
|
||||
|
||||
not_in_file_ok(README =>
|
||||
"The README is used..." => qr/The README is used/,
|
||||
"'version information here'" => qr/to provide version information/,
|
||||
);
|
||||
|
||||
not_in_file_ok(Changes =>
|
||||
"placeholder date/time" => qr(Date/time)
|
||||
);
|
||||
|
||||
module_boilerplate_ok('lib/BackupPC/Backups/Info.pm');
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue