X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_ArchiveStart;h=e8341f58d5f08f98d05520cddd11caa19aa3c8f2;hp=da3ef770c7b3ade765b063bf48da195b502fcdee;hb=c615e1bfc6f2b0604a2658996f5dd6b6cfa9469c;hpb=5dd40a3be1f8798659f7f84f0769d91beb159091 diff --git a/bin/BackupPC_ASA_ArchiveStart b/bin/BackupPC_ASA_ArchiveStart index da3ef77..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 @@ -106,28 +106,7 @@ foreach my $host ( keys %$Hosts ) { 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 ) {