1 |
#!/usr/bin/perl |
#!/usr/local/bin/perl |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use lib "__INSTALLDIR__/lib"; |
use lib "/data/backuppc-agi//lib"; |
5 |
|
|
6 |
use DBI; |
use DBI; |
7 |
use BackupPC::Lib; |
use BackupPC::Lib; |
12 |
use File::Which; |
use File::Which; |
13 |
use File::Path; |
use File::Path; |
14 |
use Filesys::Df; |
use Filesys::Df; |
15 |
|
use Cwd qw/abs_path/; |
16 |
use Data::Dumper; |
use Data::Dumper; |
17 |
|
|
18 |
my $debug = 0; |
my $debug = 0; |
33 |
my $eject_opts = $Conf{ejectOpts} || die "Need ejectOpts in config.pl\n"; |
my $eject_opts = $Conf{ejectOpts} || die "Need ejectOpts in config.pl\n"; |
34 |
$conf_bin->{'mkisofs'} = $Conf{mkisofsBin} || die "Need mkisofsBin in config.pl\n"; |
$conf_bin->{'mkisofs'} = $Conf{mkisofsBin} || die "Need mkisofsBin in config.pl\n"; |
35 |
|
|
36 |
|
my $path = abs_path($0); |
37 |
|
$path =~ s#/[^/]+$#/#; |
38 |
|
my $tarIncCreate = $path .= 'BackupPC_tarIncCreate'; |
39 |
|
|
40 |
my $bin; |
my $bin; |
41 |
foreach my $c (qw/cdrecord eject mkisofs/) { |
foreach my $c (qw/cdrecord eject mkisofs/) { |
397 |
# this part |
# this part |
398 |
my $p = { |
my $p = { |
399 |
filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}), |
filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}), |
400 |
|
host => $row->{'host'}, |
401 |
|
share => $row->{'share'}, |
402 |
|
num => $row->{'num'} |
403 |
}; |
}; |
404 |
foreach my $fld (qw/part_nr md5/) { |
foreach my $fld (qw/part_nr md5/) { |
405 |
$p->{$fld} = $row->{$fld} || die "missing $fld in row!"; |
$p->{$fld} = $row->{$fld} || die "missing $fld in row!"; |
412 |
|
|
413 |
# check available disk space |
# check available disk space |
414 |
|
|
415 |
my $df = df($iso_dir); |
my $df = df($iso_dir)->{bavail} || die "can't get free space on $iso_dir"; |
416 |
|
$df *= 1024; # calulate space in bytes |
417 |
if ($df < $v_size) { |
if ($df < $v_size) { |
418 |
warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( df($iso_dir) ), "]\n"; |
warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( $df ), " on $iso_dir]\n"; |
419 |
next; |
next; |
420 |
} |
} |
421 |
|
|
475 |
} |
} |
476 |
$rel_path .= '.tar.gz'; |
$rel_path .= '.tar.gz'; |
477 |
|
|
478 |
skip "can't find increment $rel_path: $!" unless (-r "$tar_dir/$rel_path"); |
|
479 |
|
unless (-r "$tar_dir/$rel_path") { |
480 |
|
print "WARNING: can't find increment $rel_path , trying to recreate it using BackupPC_tarIncCreate...\n"; |
481 |
|
my $host = $p->{host}; |
482 |
|
my $share = $p->{share}; |
483 |
|
my $dump = $p->{num}; |
484 |
|
|
485 |
|
my $cmd = $tarIncCreate. " -h $host -s $share -n $dump"; |
486 |
|
print "$cmd "; |
487 |
|
if (system($cmd) != 0) { |
488 |
|
print " FAILED.\n"; |
489 |
|
} else { |
490 |
|
print " done.\n"; |
491 |
|
} |
492 |
|
} |
493 |
|
|
494 |
|
skip "can't find increment $rel_path, recreateing obviously did not work: $!" unless (-r "$tar_dir/$rel_path"); |
495 |
|
|
496 |
add_symlink("$tar_dir/$rel_path", "$stage/$rel_path"); |
add_symlink("$tar_dir/$rel_path", "$stage/$rel_path"); |
497 |
|
|
498 |
my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p); |
my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p); |
536 |
|
|
537 |
print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n"; |
print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n"; |
538 |
|
|
539 |
|
die("debugging only!"); |
540 |
|
|
541 |
system($bin->{'eject'}.' '.$eject_opts) == 0 or skip "can't run eject: $?"; |
system($bin->{'eject'}.' '.$eject_opts) == 0 or skip "can't run eject: $?"; |
542 |
|
|
543 |
my $wait = <STDIN>; |
my $wait = <STDIN>; |
553 |
$sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr); |
$sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr); |
554 |
|
|
555 |
print "Media burn for $disk_name copy $copy_nr recorded\n"; |
print "Media burn for $disk_name copy $copy_nr recorded\n"; |
556 |
|
|
557 |
|
if ($copy_nr >= $copies) { |
558 |
|
print STDERR "erasing temporary files, have $copy_nr copies (> $copies)\n"; |
559 |
|
foreach my $f (( $xml_file, $iso_file )) { |
560 |
|
print STDERR "\t$f "; |
561 |
|
unlink $f || die "can't remove $f: $!"; |
562 |
|
print STDERR "removed\n"; |
563 |
|
} |
564 |
|
} |
565 |
|
|
566 |
$volume_nr++; |
$volume_nr++; |
567 |
} |
} |
568 |
|
|