);
}
-sub getVolumes($) {
- my $id = shift;
-
- my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize";
-
- my $sth = $dbh->prepare(qq{
- select
- size
- from backup_parts
- where backup_id = ?
- order by part_nr asc
- });
-
- $sth->execute($id);
-
- my $cumulative_size = 0;
- my $volumes = 1;
-
- while(my ($size) = $sth->fetchrow_array) {
- if ($cumulative_size + $size > $max_archive_size) {
- $volumes++;
- $cumulative_size = $size;
- } else {
- $cumulative_size += $size;
- }
- }
-
- return ($volumes,$cumulative_size);
-}
sub getBackupsNotBurned($) {
print STDERR "## sort=". ($param->{'sort'} || 'no sort param') . " burn sql order: $order\n";
my $sql = qq{
- SELECT
- backups.hostID AS hostID,
- hosts.name AS host,
- shares.name AS share,
- backups.num AS backupnum,
- backups.type AS type,
- backups.date AS date,
- date_part('epoch',now()) - backups.date as age,
- backups.size AS size,
- backups.id AS id,
- backups.inc_size AS inc_size,
- backups.parts AS parts
- FROM backups
- INNER JOIN shares ON backups.shareID=shares.ID
- INNER JOIN hosts ON backups.hostID = hosts.ID
- LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id
- WHERE backups.inc_size > 0 AND backups.size > 0 AND backups.inc_deleted is false AND archive_backup.backup_id IS NULL AND backups.parts > 0
- GROUP BY
- backups.hostID,
- hosts.name,
- shares.name,
- backups.num,
- backups.shareid,
- backups.id,
- backups.type,
- backups.date,
- backups.size,
- backups.inc_size,
- backups.parts
- ORDER BY $order
+ SELECT
+ p.id,
+ p.filename,
+ b.date,
+ date_part('epoch',now()) - b.date as age,
+ p.size,
+ count(ab.date) as copies
+ FROM backup_parts p
+ JOIN backups b ON b.id = p.backup_id
+ LEFT OUTER JOIN archive_parts ap ON ap.backup_part_id = p.id
+ LEFT OUTER JOIN archive_burned ab ON ab.archive_id = ap.archive_id
+ GROUP BY p.id,filename,b.date,age,p.size,p.part_nr
+ ORDER BY b.date,p.part_nr
};
my $sth = $dbh->prepare( $sql );
my @ret;
while ( my $row = $sth->fetchrow_hashref() ) {
$row->{'age'} = sprintf("%0.1f", ( $row->{'age'} / 86400 ) );
#$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) );
-
- my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize";
- if ($row->{size} > $max_archive_size) {
- ($row->{volumes}, $row->{inc_size_calc}) = getVolumes($row->{id});
- }
-
- # do some cluster calculation (approximate)
- $row->{inc_size} = int(( ($row->{inc_size} + 1023 ) / 2 ) * 2);
- $row->{inc_size_calc} ||= $row->{inc_size};
push @ret, $row;
}
suma -= size;
}
- var volumes = parseInt( element_id("prt" + name).value);
- debug('update_size('+name+','+checked+') suma: '+suma+' volumes: '+volumes);
+ debug('update_size('+name+','+checked+') suma: '+suma);
+/* FIXME
if (volumes > 1) {
if (checked) {
element_id("volumes").innerHTML = "This will take "+volumes+" mediums!";
element_id("volumes").style.display = 'none';
}
}
-
+*/
return suma;
}
<input type="checkbox" name="allFiles" id="allFiles" onClick="checkAll('allFiles');">
</td>
} .
- sort_header($param, 'Share', 'share', 'center') .
- sort_header($param, '#', 'num', 'center') .
- qq{
- <td align="center">Type</td>
- } .
+ sort_header($param, 'Filename', 'filename', 'left') .
sort_header($param, 'Date', 'date', 'center') .
sort_header($param, 'Age/days', 'age', 'center') .
sort_header($param, 'Size', 'size', 'center') .
- sort_header($param, 'gzip size', 'incsize', 'center') .
qq{
- <td align="center">medias</td></tr>
+ <td align="center">copies</td></tr>
};
my @color = (' bgcolor="#e0e0e0"', '');
- my $i = 0;
- my $host = '';
+ my $i = 1;
+# my $img_url = $Conf{CgiImageDirURL};
foreach my $backup ( getBackupsNotBurned($param) ) {
- if ($host ne $backup->{'host'}) {
- $i++;
- $host = $backup->{'host'};
- }
- my $ftype = "";
-
- my $checkbox_key = $backup->{'hostid'}. '_' .$backup->{'backupnum'} . '_' . $backup->{'id'};
-
- $retHTML .=
- '<tr' . $color[$i %2 ] . '>
- <td class="fview">';
-
- if (($backup->{'inc_size'} || 0) > 0) {
- $retHTML .= '
- <input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">';
- }
-
- my $img_url = $Conf{CgiImageDirURL};
-
- $retHTML .=
- '</td>' .
- '<td align="right">' . $backup->{'host'} . ':' . $backup->{'share'} . '</td>' .
- '<td align="center">' . $backup->{'backupnum'} . '</td>' .
- '<td align="center">' . $backup->{'type'} . '</td>' .
- '<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' .
- '<td align="center">' . $backup->{'age'} . '</td>' .
- '<td align="right">' . unit($backup->{'size'}) . '</td>' .
- '<td align="right">' . unit($backup->{'inc_size'}) . '</td>' .
- '<input type="hidden" id="fss'.$checkbox_key .'" value="'. $backup->{'inc_size_calc'} .'"></td>' .
- '<input type="hidden" id="prt'.$checkbox_key .'" value="'. $backup->{'volumes'} .'"></td>' .
- '<td align="left">' . ( qq{<img src="$img_url/icon-cd.gif" alt="media">} x $backup->{volumes} ) . '</td>' .
-
- "</tr>\n";
+ $retHTML .= join(''
+ ,'<tr',$color[$i++%2],'>'
+ ,'<td class="fview">'
+ ,'<input type="checkbox" name="fcb',$backup->{id},'" value="',$backup->{id},'" onClick="sumiraj(this);">'
+ ,'<input type="hidden" id="fss',$backup->{id},'" value="',$backup->{size},'">'
+ ,'</td>'
+ ,'<td align="left">', $backup->{'filename'}, '</td>'
+ ,'<td align="center">', epoch_to_iso( $backup->{'date'} ), '</td>'
+ ,'<td align="center">', $backup->{'age'}, '</td>'
+ ,'<td align="right">', unit($backup->{'size'}), '</td>'
+ ,'<td align="left">', '*' x $backup->{copies}, '</td>'
+ ,"</tr>\n"
+ );
}
$retHTML .= "</table>";