16 |
my $debug = 0; |
my $debug = 0; |
17 |
$|=1; |
$|=1; |
18 |
|
|
19 |
my $cdr_opts = 'dev=/dev/hdc blank=fast -v -eject'; |
# don't check for user |
20 |
|
my $bpc = BackupPC::Lib->new(undef, undef, 1) || die; |
21 |
|
my %Conf = $bpc->Conf(); |
22 |
|
%BackupPC::SearchLib::Conf = %Conf; |
23 |
|
|
24 |
|
my $cdrecord = $Conf{CDRecordBin} || die "Need CDRecordBin in config.pl\n"; |
25 |
|
my $cdr_opts = $Conf{CDRecordOpts} || die "Need CDRecordOpts in config.pl\n"; |
26 |
|
|
27 |
|
|
28 |
my $bin; |
my $bin; |
29 |
foreach my $c (qw/mkisofs cdrecord eject/) { |
foreach my $c (qw/mkisofs eject/, $cdrecord) { |
30 |
$bin->{$c} = which($c) || die "$0 needs $c, install it\n"; |
$bin->{$c} = which($c) || die "$0 needs $c, install it\n"; |
31 |
} |
} |
32 |
|
|
34 |
|
|
35 |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
36 |
|
|
|
# don't check for user |
|
|
my $bpc = BackupPC::Lib->new(undef, undef, 1) || die; |
|
|
my %Conf = $bpc->Conf(); |
|
|
%BackupPC::SearchLib::Conf = %Conf; |
|
37 |
|
|
38 |
my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
39 |
my $user = $Conf{SearchUser} || ''; |
my $user = $Conf{SearchUser} || ''; |
67 |
sub dumpArchive2XML($$$) |
sub dumpArchive2XML($$$) |
68 |
{ |
{ |
69 |
my ($dbh, $dvd_nr, $filename) = @_; |
my ($dbh, $dvd_nr, $filename) = @_; |
70 |
my %archive; |
my %archive; |
71 |
my $output = new IO::File(">$filename"); |
|
72 |
|
my $output = new IO::File('> '.$filename.'.tmp'); |
73 |
my $writer = new XML::Writer(OUTPUT=>$output, NEWLINES => 1); |
my $writer = new XML::Writer(OUTPUT=>$output, NEWLINES => 1); |
74 |
|
|
75 |
|
print "Dumping file list for DVD $dvd_nr, countdown:"; |
76 |
|
|
77 |
$writer->pi('xml-stylesheet', 'href="archive.css" type="text/css"'); |
$writer->pi('xml-stylesheet', 'href="archive.css" type="text/css"'); |
78 |
|
|
79 |
my $files_sql = q{ |
my $files_sql = q{ |
124 |
my $sth_backups = $dbh->prepare( $backups_sql ); |
my $sth_backups = $dbh->prepare( $backups_sql ); |
125 |
$sth_backups->execute( $row_h->{'id'} ); |
$sth_backups->execute( $row_h->{'id'} ); |
126 |
|
|
127 |
|
my $total_backups = $sth_backups->rows; |
128 |
|
my $curr_backup = 0; |
129 |
|
my $last_pcnt = 0; |
130 |
|
|
131 |
while (my $row = $sth_backups->fetchrow_hashref()) { |
while (my $row = $sth_backups->fetchrow_hashref()) { |
132 |
|
|
133 |
|
$curr_backup++; |
134 |
|
my $pcnt = int(($curr_backup * 10) / $total_backups); |
135 |
|
if ($pcnt > $last_pcnt) { |
136 |
|
print " ",(10 - $pcnt); |
137 |
|
$last_pcnt = $pcnt; |
138 |
|
} |
139 |
|
|
140 |
my $sth_files = $dbh->prepare( $files_sql); |
my $sth_files = $dbh->prepare( $files_sql); |
141 |
$sth_files->execute($row->{'backup_id'}); |
$sth_files->execute($row->{'backup_id'}); |
142 |
|
|
160 |
|
|
161 |
$writer->endTag("archive"); |
$writer->endTag("archive"); |
162 |
$writer->end(); |
$writer->end(); |
163 |
|
|
164 |
|
rename $filename.'.tmp', $filename || die "can't rename $filename: $!"; |
165 |
|
|
166 |
|
print "\n"; |
167 |
} |
} |
168 |
|
|
169 |
|
|
260 |
|
|
261 |
my $sth_archive_burned = $dbh->prepare( qq{ |
my $sth_archive_burned = $dbh->prepare( qq{ |
262 |
insert into archive_burned |
insert into archive_burned |
263 |
(archive_id, iso_size, part) |
(archive_id, iso_size, part, copy) |
264 |
values ( (select id from archive where dvd_nr =?), ?, ?) |
values ( (select id from archive where dvd_nr =?), ?, ?, ?) |
265 |
}); |
}); |
266 |
|
|
267 |
foreach my $arc (@archives_to_burn) { |
foreach my $arc (@archives_to_burn) { |
305 |
print "Processing part $part_nr/$parts\n"; |
print "Processing part $part_nr/$parts\n"; |
306 |
|
|
307 |
my $list_file = my $iso_file = my $xml_file = "${iso_dir}/${dvd_nr}"; |
my $list_file = my $iso_file = my $xml_file = "${iso_dir}/${dvd_nr}"; |
308 |
$list_file .= '.list'; |
$list_file .= $part_path . '.list'; |
309 |
$iso_file .= $part_path . '.iso'; |
$iso_file .= $part_path . '.iso'; |
310 |
$xml_file .= '.xml'; |
$xml_file .= '.xml'; |
311 |
|
|
326 |
print $list "$tar_dir/$tar_file\n"; |
print $list "$tar_dir/$tar_file\n"; |
327 |
} else { |
} else { |
328 |
my $len = length("$parts"); |
my $len = length("$parts"); |
329 |
my $nr = sprintf("%0${len}d", $part_nr); |
my $nr = sprintf("%0${len}d", ($part_nr - 1)); |
330 |
print $list "$tar_dir/$tar_file/part$nr\n"; |
print $list "$tar_dir/$tar_file/part$nr\n"; |
331 |
} |
} |
332 |
$inc++; |
$inc++; |
360 |
print "ISO $iso_file allready exists\n"; |
print "ISO $iso_file allready exists\n"; |
361 |
} |
} |
362 |
|
|
363 |
print "\nREADY TO BURN MEDIA $disk_name please insert blank media and press ENTER\n\n"; |
my $copies = $Conf{BurnMultipleCopies} || 1; |
364 |
|
|
365 |
|
foreach my $copy_nr ( 1 .. $copies ) { |
366 |
|
|
367 |
system($bin->{'eject'}) == 0 or skip "can't run eject: $?"; |
print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n"; |
368 |
|
|
369 |
my $wait = <STDIN>; |
system($bin->{'eject'}) == 0 or skip "can't run eject: $?"; |
370 |
|
|
371 |
my $cmd = $bin->{'cdrecord'} . ' ' . $cdr_opts . ' ' . $iso_file; |
my $wait = <STDIN>; |
372 |
|
|
373 |
# system($cmd) == 0 or skip "can't run $cmd: $?"; |
my $cmd = $bin->{$cdrecord} . ' ' . $cdr_opts . ' ' . $iso_file; |
|
print "## $cmd\n"; |
|
374 |
|
|
375 |
print "\n\nPLEASE REMOVE DVD MEDIA AND LABEL IT WITH $disk_name\n\n"; |
# FIXME |
376 |
|
print "## $cmd\n"; |
377 |
|
system($cmd) == 0 or skip "can't run $cmd: $?"; |
378 |
|
|
379 |
$sth_archive_burned->execute($dvd_nr, $iso_size, $part_nr); |
print "\n\nPLEASE REMOVE DVD MEDIA AND LABEL IT WITH $disk_name\n\n"; |
380 |
|
|
381 |
print "Media burn for $disk_name recorded\n"; |
$sth_archive_burned->execute($dvd_nr, $iso_size, $part_nr, $copy_nr); |
382 |
|
|
383 |
|
print "Media burn for $disk_name copy $copy_nr recorded\n"; |
384 |
|
} |
385 |
|
|
386 |
$part_nr++; |
$part_nr++; |
387 |
} until ($part_nr > $parts); |
} until ($part_nr > $parts); |