X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_ArchiveStart;h=c446363df2e9d5ca69fe76d91c87e19f850a79fd;hp=669a0c142907324a22b421886793d406724db645;hb=7cc35df2d8753d1eddd17d3f377fffd6ef316c1d;hpb=34311ffcf9578586eb9a2e2a766af24afd0816d4 diff --git a/bin/BackupPC_ASA_ArchiveStart b/bin/BackupPC_ASA_ArchiveStart index 669a0c1..c446363 100755 --- a/bin/BackupPC_ASA_ArchiveStart +++ b/bin/BackupPC_ASA_ArchiveStart @@ -49,15 +49,16 @@ use Getopt::Std; use BackupPC::Lib; use DBI; +use Data::Dump qw(dump); die("BackupPC::Lib->new failed\n") if ( !(my $bpc = BackupPC::Lib->new) ); my %opts; # no options currently -if ( !getopts("", \%opts) || @ARGV < 3 ) { +if ( !getopts("", \%opts) || @ARGV < 2 ) { print STDERR <prepare(qq{ }); my $Hosts = $bpc->HostInfoRead(); -my $ArchiveHost = $ARGV[0]; -my $UserName = $ARGV[1]; +my $ArchiveHost = shift @ARGV; +my $UserName = shift @ARGV; +my @HostFilter = @ARGV; my $TopDir = $bpc->{Conf}{TopDir}; if ( !defined($Hosts->{$ArchiveHost}) ) { @@ -87,23 +89,30 @@ if ( !defined($Hosts->{$ArchiveHost}) ) { } $bpc->ConfigRead($ArchiveHost); +if ( ! @HostFilter ) { + @HostFilter = keys %$Hosts; +} + +warn "archiving hosts ",dump(@HostFilter); + my(@HostList, @BackupList); -for ( my $i = 2 ; $i < @ARGV ; $i++ ) { - my ($host,$num) = split(/:/,$ARGV[$i],2); +foreach ( @HostFilter ) { + my ($host,$num) = split(/:/,$_,2); if ( !defined($Hosts->{$host}) ) { print(STDERR "$0: host $host doesn't exist... quitting\n"); exit(1); } my @backups = $bpc->BackupInfoRead($host); if ( !@backups ) { - print(STDERR "$0: host $host doesn't have any backups... quitting\n"); - exit(1); + warn "$0: host $host doesn't have any backups... skipping\n"; + next; } $sth->execute( $host ); if ( $sth->rows == 0 ) { warn "no backups to archive on $host\n"; - next; + push @HostList, $host; + push @BackupList, 0; # fake, but will make full-text update } while ( my $row = $sth->fetchrow_hashref ) { @@ -113,6 +122,8 @@ for ( my $i = 2 ; $i < @ARGV ; $i++ ) { } } +$dbh->disconnect; + my $ReqFileName; for ( my $i = 0 ; ; $i++ ) { $ReqFileName="archiveReq.$$.$i"; @@ -127,7 +138,7 @@ my %ArchiveReq = ( compext => $bpc->{Conf}{ArchiveComp} eq 'none' ? '' : ($bpc->{Conf}{ArchiveComp} eq 'gzip' ? '.gz' : '.bz2'), parfile => $bpc->{Conf}{ArchivePar}, - splitsize => '0000000', + splitsize => $bpc->{Conf}{ArchiveSplit}, host => $ArchiveHost, HostList => \@HostList, BackupList => \@BackupList,