+sub getVolumes($) {
+ my $id = shift;
+
+ my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
+
+ 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);
+}
+