added common BackupPC::Search::host_backup_nums
[BackupPC.git] / bin / BackupPC_ASA_SearchUpdate
index cb2dcd1..ba499f9 100755 (executable)
@@ -312,14 +312,15 @@ my $host_nr = 0;
 foreach my $host_key (@hosts) {
 
        my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";
+       $hostname = lc $hostname;
 
-       next if $opt->host && ! grep { m/^$hostname$/ } @{ $opt->host };
+       next if $opt->host && ! grep { m/^$hostname$/i } @{ $opt->host };
 
        $sth->{hosts_by_name}->execute($hostname);
 
        unless (($hostID) = $sth->{hosts_by_name}->fetchrow_array()) {
                $sth->{insert_hosts}->execute(
-                       $hosts->{$host_key}->{'host'},
+                       $hostname,
                        $hosts->{$host_key}->{'ip'}
                );
 
@@ -710,8 +711,8 @@ create table archive_burned (
 --from backups
 --join shares on backups.shareid=shares.id
 --join hosts on shares.hostid = hosts.id
---left outer join archive_backup on backups.id = archive_backup.backup_id
---left outer join archive on archive_backup.archive_id = archive.id
+--left outer join archive_backup_parts on backups.id = archive_backup_parts.backup_id
+--left outer join archive on archive_backup_parts.archive_id = archive.id
 --where backups.parts > 0 and size > 0
 --order by backups.date
 --;
@@ -740,10 +741,22 @@ JOIN archive       ON archive_id = archive.id
 JOIN backups       ON backup_id = backups.id
 JOIN hosts         ON hostid = hosts.id
 JOIN shares        ON shareid = shares.id
-ORDER BY backup_id, part_nr
 ;
 
 
+CREATE VIEW backups_burned AS
+SELECT backup_parts.backup_id,
+count(backup_parts.backup_id) as backup_parts,
+count(archive_burned.archive_id) AS burned_parts,
+count(backup_parts.backup_id) = count(archive_burned.archive_id) as burned
+   FROM backup_parts 
+   left outer JOIN archive_parts ON backup_part_id = backup_parts.id
+   left join archive on archive.id = archive_id
+   left outer join archive_burned on archive_burned.archive_id = archive.id
+  GROUP BY backup_parts.backup_id ;
+
+
+-- triggers for backup_parts consistency
 create or replace function backup_parts_check() returns trigger as '
 declare
        b_parts integer;