X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_ArchiveStart;h=e8341f58d5f08f98d05520cddd11caa19aa3c8f2;hp=f91a60f6078a035cf7edae468f771c67e783a832;hb=c615e1bfc6f2b0604a2658996f5dd6b6cfa9469c;hpb=50c9c2c571189eeac7eefdd5b8e536163d685757 diff --git a/bin/BackupPC_ASA_ArchiveStart b/bin/BackupPC_ASA_ArchiveStart index f91a60f..e8341f5 100755 --- a/bin/BackupPC_ASA_ArchiveStart +++ b/bin/BackupPC_ASA_ArchiveStart @@ -47,8 +47,8 @@ no utf8; use lib "/usr/local/BackupPC/lib"; use Getopt::Std; use BackupPC::Lib; +use BackupPC::Search; -use DBI; use Data::Dump qw(dump); my $debug = $ENV{DEBUG} || 0; @@ -67,7 +67,7 @@ EOF my %Conf = $bpc->Conf(); -my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 }); +my $dbh = BackupPC::Search::get_dbh; my $sth = $dbh->prepare(qq{ select @@ -100,33 +100,13 @@ my(@HostList, @BackupList); my $host_nums; foreach my $host ( keys %$Hosts ) { + $host = lc $host; my @backups = $bpc->BackupInfoRead($host); if ( !@backups ) { warn "$0: host $host doesn't have any backups... skipping\n"; next; } - - my $all_backup_numbers; - $all_backup_numbers->{ $_->{num} }++ foreach @backups; - - $sth->execute( $host ); - while ( my $row = $sth->fetchrow_hashref ) { - warn "# row ",dump($row) if $debug; - $all_backup_numbers->{ $row->{num} } = - $row->{inc_deleted} ? 0 : - $row->{size} == 0 ? 0 : - $row->{inc_size} > 0 ? 0 : - $row->{size} > 0 ? 1 : - 0; - } - - warn "# $host all_backup_numbers = ",dump($all_backup_numbers),"\n"; - - $host_nums->{$host} = [ - sort - grep { $all_backup_numbers->{$_} } - keys %$all_backup_numbers - ]; + $host_nums->{$host} = [ BackupPC::Search::host_backup_nums( $host ) ]; } foreach ( @HostFilter ) {