31 |
EOF |
EOF |
32 |
|
|
33 |
$cont .= "Backups that have not been archived:<br>"; |
$cont .= "Backups that have not been archived:<br>"; |
34 |
$cont .= BackupPC::SearchLib::displayBackupsGrid(); |
$cont .= BackupPC::SearchLib::displayBackupsGrid( \%In ); |
35 |
|
|
36 |
} else { |
} else { |
37 |
|
|
38 |
my @selected_backup_ids; |
my @selected_backup_ids; |
39 |
|
|
40 |
my $total_size = 0; |
my $total_size = 0; |
41 |
|
my $selected = 0; |
42 |
|
|
43 |
foreach my $key(keys(%In)) { |
foreach my $key(keys(%In)) { |
44 |
if ($key =~ m/^fcb([0-9]+)_([0-9]+)_([0-9]+)$/gi) { |
if ($key =~ m/^fcb([0-9]+)_([0-9]+)_([0-9]+)$/gi) { |
45 |
my ($host_id, $backup_num, $backup_id) = ($1,$2,$3); |
my ($host_id, $backup_num, $backup_id) = ($1,$2,$3); |
46 |
push @selected_backup_ids, $backup_id; |
push @selected_backup_ids, $backup_id; |
47 |
$total_size += BackupPC::SearchLib::getGzipSize($host_id, $backup_num); |
$total_size += BackupPC::SearchLib::getGzipSize($host_id, $backup_num); |
48 |
|
$selected++; |
49 |
} |
} |
50 |
} |
} |
51 |
|
|
52 |
# convert to Kb |
# and now a little magic to check multi-volume increments |
53 |
$total_size = $total_size / 1024; |
my $parts = 1; |
54 |
|
if ($#selected_backup_ids == 0) { |
55 |
|
($parts) = $dbh->selectrow_array("select parts from backups where id = ?", undef, $selected_backup_ids[0]); |
56 |
|
} |
57 |
|
|
58 |
if ($total_size > $Conf{MaxArchiveSize}) { |
if ($total_size > ($Conf{MaxArchiveSize} * $parts)) { |
59 |
|
$cont .= eval( q{ ${h2(Error)}}); |
60 |
|
$cont .= "Selected backups size $total_size Kb exceed max archive size $Conf{MaxArchiveSize} Kb."; |
61 |
|
} elsif ($total_size == 0) { |
62 |
$cont .= eval( q{ ${h2(Error)}}); |
$cont .= eval( q{ ${h2(Error)}}); |
63 |
$cont .= "Selected backups size $total_size exceed max archive size $Conf{MaxArchiveSize}."; |
$cont .= "No backups selected."; |
64 |
} else { |
} else { |
65 |
|
|
66 |
# create new archive |
# create new archive |
70 |
dvd_nr, |
dvd_nr, |
71 |
note, |
note, |
72 |
username, |
username, |
73 |
date |
date, |
74 |
|
total_size |
75 |
) VALUES ( |
) VALUES ( |
76 |
nextVal('archive_id_seq'), |
nextVal('archive_id_seq'), |
77 |
nextVal('dvd_nr'), |
nextVal('dvd_nr'), |
78 |
?, |
?, |
79 |
?, |
?, |
80 |
NOW() |
NOW(), |
81 |
|
? |
82 |
) |
) |
83 |
}); |
}); |
84 |
|
|
85 |
# FIXME insert user here |
$sth->execute($In{'note'}, $User, $total_size); |
|
$sth->execute($In{'note'}, 'dummy_user'); |
|
86 |
|
|
87 |
foreach my $backup_id (@selected_backup_ids) { |
foreach my $backup_id (@selected_backup_ids) { |
88 |
|
|
113 |
Archived following backups: |
Archived following backups: |
114 |
} . join(", ", @selected_backup_ids) . q{ |
} . join(", ", @selected_backup_ids) . q{ |
115 |
<br/>with total size of |
<br/>with total size of |
116 |
<b>} . sprintf("%1.2f Mb", $total_size / 1024) . q{</b> |
<b>} . sprintf("%1.2f Mb", $total_size / 1024 / 1024) . q{</b> |
117 |
to media <b>} . $dvd_nr . q{</b> |
to media <b>} . $dvd_nr . q{</b> |
118 |
with following message: |
with following message: |
119 |
<div style="background-color: #e0e0e0; display: inline; padding: 2px;"> |
<div style="background-color: #e0e0e0; display: inline; padding: 2px;"> |