# Craig Barratt <cbarratt@users.sourceforge.net>
#
# COPYRIGHT
-# Copyright (C) 2003 Craig Barratt
+# Copyright (C) 2003-2009 Craig Barratt
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#
#========================================================================
#
-# Version 3.0.0beta0, released 11 Jul 2006.
+# Version 3.2.0, released 31 Jul 2010.
#
# See http://backuppc.sourceforge.net.
#
use strict;
use BackupPC::CGI::Lib qw(:all);
use Data::Dumper;
+use DBI;
sub action
{
my($fullDur, $incrCnt, $fullSize, $fullRate);
my @Backups = $bpc->BackupInfoRead($host);
my $fullCnt = $incrCnt = 0;
+ my $all_backup_numbers;
+
for ( my $i = 0 ; $i < @Backups ; $i++ ) {
if ( $Backups[$i]{type} eq "full" ) {
$fullSize = $Backups[$i]{size} / (1024 * 1024);
$incrSizeTot = $Backups[$i]{size} / (1024 * 1024);
}
$backupnumber = $Backups[$i]{num};
+ $all_backup_numbers->{$backupnumber}++;
}
$fullSizeTot += $fullSize + $incrSizeTot;
$fullSize = sprintf("%.2f", ($fullSize + $incrSizeTot) / 1000);
+
+ $bpc->ConfigRead($archHost);
+ %Conf = $bpc->Conf();
+
+use Data::Dump qw(dump);
+
+ my $dbh = DBI->connect($Conf{SearchDSN}, $Conf{SearchUser}, "", { RaiseError => 1, AutoCommit => 0 });
+ my $sth = $dbh->prepare(qq{
+ select
+ hosts.name as host, -- FIXME for debug
+ backups.num as num,
+ inc_size,
+ size,
+ inc_deleted
+ from backups
+ join hosts on hosts.id = hostid
+ where hosts.name = ?
+ });
+ $sth->execute($host);
+ # and inc_size < 0 and size > 0 and not inc_deleted
+ while( my $row = $sth->fetchrow_hashref ) {
+warn "# row ",dump $row;
+ $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 $host all_backup_numbers = ",dump($all_backup_numbers);
+ my @backup_nums =
+ sort
+ grep { $all_backup_numbers->{$_} }
+ keys %$all_backup_numbers;
+
+ my $checkboxes;
+ foreach my $backupnumber ( @backup_nums ) {
+ $checkboxes .= qq|
+<input type="hidden" name="fcb$checkBoxCnt" value="$host">
+<input type="checkbox" name="backup$checkBoxCnt" value="$backupnumber">$backupnumber
+ |;
+ $checkBoxCnt++;
+ }
+
+=for ASA extension removed this
$str = <<EOF;
<tr>
<td class="border"><input type="hidden" name="backup$checkBoxCnt" value="$backupnumber"><input type="checkbox" name="fcb$checkBoxCnt" value="$host"> ${HostLink($host)} </td>
<td align="center" class="border"> $fullSize </td>
EOF
$checkBoxCnt++;
+=cut
+
+ $str = <<EOF;
+<tr>
+<td class="border">
+${HostLink($host)}
+$checkboxes
+</td>
+<td align="center" class="border">
+${UserLink($Hosts->{$host}{user})}
+</td>
+<td align="center" class="border"> $fullSize </td>
+EOF
+
if ( @Backups == 0 ) {
$hostCntNone++;
$strNone .= $str;
next if ( !defined($In{"fcb$i"}) );
my $name = $In{"fcb$i"};
my $backupno = $In{"backup$i"};
+ next unless defined $backupno; # ASA - skip hosts without backups checked
push(@HostList, $name);
push(@BackupList, $backupno);
$hiddenStr .= <<EOF;
<input type="hidden" name="backup$i" value="$In{'backup' . $i}">
EOF
$HostListStr .= <<EOF;
-<li> ${EscHTML($name)}
+<li> ${EscHTML($name)} $i
EOF
}
$hiddenStr .= <<EOF;
$compname = $Conf{CatPath};
$compext = '.raw';
}
- my $fullsplitsize = $In{splitsize} . '000000';
+ my $fullsplitsize = $In{splitsize} . '000000'; # mb -> bytes
my %ArchiveReq = (
# parameters for the archive
archiveloc => $In{archive_device},