8 |
use DateTime; |
use DateTime; |
9 |
use vars qw(%In $MyURL); |
use vars qw(%In $MyURL); |
10 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
11 |
|
use XML::Writer; |
12 |
|
use IO::File; |
13 |
|
|
14 |
my $on_page = 100; |
my $on_page = 100; |
15 |
my $pager_pages = 10; |
my $pager_pages = 10; |
70 |
$mm =~ s/\D//g; |
$mm =~ s/\D//g; |
71 |
$dd =~ s/\D//g; |
$dd =~ s/\D//g; |
72 |
|
|
73 |
|
my $h = my $m = my $s = 0; |
74 |
|
if ($suffix eq 'to') { |
75 |
|
$h = 23; |
76 |
|
$m = 59; |
77 |
|
$s = 59; |
78 |
|
} |
79 |
|
|
80 |
my $dt = new DateTime( |
my $dt = new DateTime( |
81 |
year => $yyyy, |
year => $yyyy, |
82 |
month => $mm, |
month => $mm, |
83 |
day => $dd |
day => $dd, |
84 |
|
hour => $h, |
85 |
|
minute => $m, |
86 |
|
second => $s, |
87 |
); |
); |
88 |
print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n"; |
print STDERR "mk_epoch_date($name,$suffix) [$yyyy-$mm-$dd] = " . $dt->ymd . " " . $dt->hms . "\n"; |
89 |
return $dt->epoch || 'NULL'; |
return $dt->epoch || 'NULL'; |
112 |
push @conditions, qq{ files.date >= $files_from } if ($files_from); |
push @conditions, qq{ files.date >= $files_from } if ($files_from); |
113 |
push @conditions, qq{ files.date <= $files_to } if ($files_to); |
push @conditions, qq{ files.date <= $files_to } if ($files_to); |
114 |
|
|
115 |
print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" | ",@conditions); |
print STDERR "backup: $backup_from - $backup_to files: $files_from - $files_to cond:" . join(" and ",@conditions); |
116 |
|
|
117 |
push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'}); |
push( @conditions, ' files.shareid = ' . $param->{'search_share'} ) if ($param->{'search_share'}); |
118 |
push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'}); |
push (@conditions, " upper(files.path) LIKE upper('%".$param->{'search_filename'}."%')") if ($param->{'search_filename'}); |
300 |
$ret =~ s/\\h/$host/ge; |
$ret =~ s/\\h/$host/ge; |
301 |
$ret =~ s/\\s/$share/ge; |
$ret =~ s/\\s/$share/ge; |
302 |
$ret =~ s/\\n/$backupnum/ge; |
$ret =~ s/\\n/$backupnum/ge; |
303 |
|
|
304 |
|
$ret =~ s/__+/_/g; |
305 |
|
|
306 |
return $ret; |
return $ret; |
307 |
|
|
308 |
} |
} |
309 |
|
|
310 |
|
sub get_tgz_size_by_name($) { |
311 |
|
my $name = shift; |
312 |
|
|
313 |
|
my $tgz = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'.$name; |
314 |
|
|
315 |
|
my $size = -1; |
316 |
|
|
317 |
|
if (-f $tgz) { |
318 |
|
$size = (stat($tgz))[7]; |
319 |
|
} elsif (-d $tgz) { |
320 |
|
opendir(my $dir, $tgz) || die "can't opendir $tgz: $!"; |
321 |
|
my @parts = grep { !/^\./ && -f "$tgz/$_" } readdir($dir); |
322 |
|
$size = 0; |
323 |
|
foreach my $part (@parts) { |
324 |
|
$size += (stat("$tgz/$part"))[7] || die "can't stat $tgz/$part: $!"; |
325 |
|
} |
326 |
|
closedir $dir; |
327 |
|
} |
328 |
|
|
329 |
|
return $size; |
330 |
|
} |
331 |
|
|
332 |
sub getGzipSize($$) |
sub getGzipSize($$) |
333 |
{ |
{ |
334 |
my ($hostID, $backupNum) = @_; |
my ($hostID, $backupNum) = @_; |
|
my $ret; |
|
335 |
my $sql; |
my $sql; |
336 |
my $dbh = get_dbh(); |
my $dbh = get_dbh(); |
337 |
|
|
349 |
$sth->execute($hostID, $backupNum); |
$sth->execute($hostID, $backupNum); |
350 |
|
|
351 |
my $row = $sth->fetchrow_hashref(); |
my $row = $sth->fetchrow_hashref(); |
352 |
|
|
353 |
my (undef,undef,undef,undef,undef,undef,undef,$ret,undef,undef,undef,undef,undef) = |
return get_tgz_size_by_name( |
354 |
stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'. |
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'}) |
355 |
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})); |
); |
|
|
|
|
return $ret; |
|
356 |
} |
} |
357 |
|
|
358 |
sub getBackupsNotBurned() { |
sub getBackupsNotBurned() { |
368 |
backups.type AS type, |
backups.type AS type, |
369 |
backups.date AS date, |
backups.date AS date, |
370 |
backups.size AS size, |
backups.size AS size, |
371 |
backups.id AS id |
backups.id AS id, |
372 |
|
backups.inc_size AS inc_size |
373 |
FROM backups |
FROM backups |
374 |
INNER JOIN shares ON backups.shareID=shares.ID |
INNER JOIN shares ON backups.shareID=shares.ID |
375 |
INNER JOIN hosts ON backups.hostID = hosts.ID |
INNER JOIN hosts ON backups.hostID = hosts.ID |
376 |
LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id |
LEFT OUTER JOIN archive_backup ON archive_backup.backup_id = backups.id |
377 |
WHERE backups.size > 0 AND archive_backup.backup_id IS NULL |
WHERE backups.inc_size > 0 AND backups.inc_deleted is false AND archive_backup.backup_id IS NULL |
378 |
GROUP BY |
GROUP BY |
379 |
backups.hostID, |
backups.hostID, |
380 |
hosts.name, |
hosts.name, |
384 |
backups.id, |
backups.id, |
385 |
backups.type, |
backups.type, |
386 |
backups.date, |
backups.date, |
387 |
backups.size |
backups.size, |
388 |
|
backups.inc_size |
389 |
ORDER BY backups.date |
ORDER BY backups.date |
390 |
}; |
}; |
391 |
my $sth = $dbh->prepare( $sql ); |
my $sth = $dbh->prepare( $sql ); |
395 |
while ( my $row = $sth->fetchrow_hashref() ) { |
while ( my $row = $sth->fetchrow_hashref() ) { |
396 |
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); |
$row->{'age'} = sprintf("%0.1f", ( (time() - $row->{'date'}) / 86400 ) ); |
397 |
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); |
$row->{'size'} = sprintf("%0.2f", $row->{'size'} / 1024 / 1024); |
398 |
my (undef,undef,undef,undef,undef,undef,undef,$fs_size,undef,undef,undef,undef,undef) = |
|
399 |
stat( $Conf{InstallDir}.'/'.$Conf{GzipTempDir}.'/'. |
# do some cluster calculation (approximate) and convert to kB |
400 |
getGzipName($row->{'host'}, $row->{share}, $row->{'backupnum'})); |
$row->{'inc_size'} = int(($row->{'inc_size'} + 1023 ) / ( 2 * 1024 ) * 2); |
|
$row->{'fs_size'} = $fs_size; |
|
401 |
push @ret, $row; |
push @ret, $row; |
402 |
} |
} |
403 |
|
|
517 |
<!-- |
<!-- |
518 |
|
|
519 |
var debug_div = null; |
var debug_div = null; |
520 |
var media_size = 4400 * 1024; |
EOF3 |
521 |
|
|
522 |
|
# take maximum archive size from configuration |
523 |
|
$retHTML .= 'var media_size = '. $Conf{MaxArchiveSize} .';'; |
524 |
|
|
525 |
|
$retHTML .= <<'EOF3'; |
526 |
|
|
527 |
function debug(msg) { |
function debug(msg) { |
528 |
// return; // Disable debugging |
// return; // Disable debugging |
720 |
<td align="center">date</td> |
<td align="center">date</td> |
721 |
<td align="center">age/days</td> |
<td align="center">age/days</td> |
722 |
<td align="center">size/MB</td> |
<td align="center">size/MB</td> |
723 |
<td align="center">gzip size</td> |
<td align="center">gzip size/kB</td> |
724 |
</tr> |
</tr> |
725 |
|
|
726 |
}; |
}; |
744 |
'<tr' . $color[$i %2 ] . '> |
'<tr' . $color[$i %2 ] . '> |
745 |
<td class="fview">'; |
<td class="fview">'; |
746 |
|
|
747 |
# FIXME |
if (($backup->{'inc_size'} || 0) > 0) { |
|
$backup->{'fs_size'} = int($backup->{'size'} * 1024); |
|
|
|
|
|
if (($backup->{'fs_size'} || 0) > 0) { |
|
748 |
$retHTML .= ' |
$retHTML .= ' |
749 |
<input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">'; |
<input type="checkbox" name="fcb' . $checkbox_key . '" value="' . $checkbox_key . '" onClick="sumiraj(this);">'; |
750 |
} |
} |
757 |
'<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
'<td align="center">' . epoch_to_iso( $backup->{'date'} ) . '</td>' . |
758 |
'<td align="center">' . $backup->{'age'} . '</td>' . |
'<td align="center">' . $backup->{'age'} . '</td>' . |
759 |
'<td align="right">' . $backup->{'size'} . '</td>' . |
'<td align="right">' . $backup->{'size'} . '</td>' . |
760 |
'<td align="right">' . $backup->{'fs_size'} . |
'<td align="right">' . $backup->{'inc_size'} . |
761 |
'<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'fs_size'} .'"></td>' . |
'<input type="hidden" iD="fss'.$checkbox_key .'" value="'. $backup->{'inc_size'} .'"></td>' . |
762 |
|
|
763 |
"</tr>\n"; |
"</tr>\n"; |
764 |
} |
} |