From: Dobrica Pavlinusic Date: Thu, 27 Jan 2011 15:55:52 +0000 (+0000) Subject: create all archives which are missing for given host X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=commitdiff_plain;h=34311ffcf9578586eb9a2e2a766af24afd0816d4 create all archives which are missing for given host --- diff --git a/bin/BackupPC_ASA_ArchiveStart b/bin/BackupPC_ASA_ArchiveStart index bd294e4..669a0c1 100755 --- a/bin/BackupPC_ASA_ArchiveStart +++ b/bin/BackupPC_ASA_ArchiveStart @@ -62,6 +62,20 @@ EOF exit(1); } +my %Conf = $bpc->Conf(); + +my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 }); + +my $sth = $dbh->prepare(qq{ + select + backups.id as backup_id, + hosts.name as host, + backups.num as num + from backups + join hosts on hosts.id = hostid + where hosts.name = ? and inc_size < 0 and size > 0 and not inc_deleted +}); + my $Hosts = $bpc->HostInfoRead(); my $ArchiveHost = $ARGV[0]; my $UserName = $ARGV[1]; @@ -85,9 +99,18 @@ for ( my $i = 2 ; $i < @ARGV ; $i++ ) { print(STDERR "$0: host $host doesn't have any backups... quitting\n"); exit(1); } - push(@HostList, $host); - $num ||= $backups[$#backups]{num}; - push(@BackupList, $num); + + $sth->execute( $host ); + if ( $sth->rows == 0 ) { + warn "no backups to archive on $host\n"; + next; + } + + while ( my $row = $sth->fetchrow_hashref ) { + warn "+ ", $row->{host}, " ", $row->{num}, "\n"; + push(@HostList, $host); + push(@BackupList, $row->{num}); + } } my $ReqFileName; diff --git a/bin/BackupPC_ASA_PostArchive_Update b/bin/BackupPC_ASA_PostArchive_Update index 33527a0..e744d02 100755 --- a/bin/BackupPC_ASA_PostArchive_Update +++ b/bin/BackupPC_ASA_PostArchive_Update @@ -66,7 +66,7 @@ my $start_t = time(); my $t_fmt = '%Y-%m-%d %H:%M:%S'; -warn "## Conf = ",dump( \%Conf ); +#warn "## Conf = ",dump( \%Conf ); my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 });