X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=bin%2FBackupPC_burnArchiveCLI;h=399e2a4967224b007620629304e878ea20a51598;hb=5c07d9b6adc6a0bd05f5577809ffdc4b6ab9aea0;hp=18013c20a8d781db94dce574e9de4caa09f23199;hpb=824b4c17a9b7b79f5b2d6541559a1574e71f8624;p=BackupPC.git diff --git a/bin/BackupPC_burnArchiveCLI b/bin/BackupPC_burnArchiveCLI index 18013c2..399e2a4 100755 --- a/bin/BackupPC_burnArchiveCLI +++ b/bin/BackupPC_burnArchiveCLI @@ -1,6 +1,7 @@ -#!/usr/bin/perl +#!/usr/local/bin/perl use strict; + use lib "__INSTALLDIR__/lib"; use DBI; @@ -12,7 +13,7 @@ use Term::Menus; use File::Which; use File::Path; use Filesys::Df; - +use Cwd qw/abs_path/; use Data::Dumper; my $debug = 0; @@ -33,6 +34,9 @@ $conf_bin->{'eject'} = $Conf{ejectBin} || die "Need ejectBin in config.pl\n"; my $eject_opts = $Conf{ejectOpts} || die "Need ejectOpts in config.pl\n"; $conf_bin->{'mkisofs'} = $Conf{mkisofsBin} || die "Need mkisofsBin in config.pl\n"; +my $path = abs_path($0); +$path =~ s#/[^/]+$#/#; +my $tarIncCreate = $path .= 'BackupPC_tarIncCreate'; my $bin; foreach my $c (qw/cdrecord eject mkisofs/) { @@ -394,6 +398,9 @@ foreach my $copy_nr ( 1 .. $copies ) { # this part my $p = { filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}), + host => $row->{'host'}, + share => $row->{'share'}, + num => $row->{'num'} }; foreach my $fld (qw/part_nr md5/) { $p->{$fld} = $row->{$fld} || die "missing $fld in row!"; @@ -406,9 +413,10 @@ foreach my $copy_nr ( 1 .. $copies ) { # check available disk space - my $df = df($iso_dir); + my $df = df($iso_dir)->{bavail} || die "can't get free space on $iso_dir"; + $df *= 1024; # calulate space in bytes if ($df < $v_size) { - 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"; next; } @@ -468,8 +476,32 @@ foreach my $copy_nr ( 1 .. $copies ) { } $rel_path .= '.tar.gz'; - skip "can't find increment $rel_path: $!" unless (-r "$tar_dir/$rel_path"); + + unless (-r "$tar_dir/$rel_path") { + print "WARNING: can't find increment $rel_path , trying to recreate it using BackupPC_tarIncCreate...\n"; + my $host = $p->{host}; + my $share = $p->{share}; + my $dump = $p->{num}; + my $currUser = getlogin(); + my $otherUser = ""; + if ($currUser eq "agi") { + $otherUser = "backuppc-agi"; + } elsif ($currUser eq "qc") { + $otherUser = "backuppc-qc"; + } + if ($otherUser ne "") { + my $cmd = "sudo -u $otherUser ".$tarIncCreate. " -h $host -s $share -n $dump"; + print "$cmd "; + if (system($cmd) != 0) { + print " FAILED.\n"; + } else { + print " done.\n"; + } + } + } + skip "can't find increment $rel_path, recreateing obviously did not work: $!" unless (-r "$tar_dir/$rel_path"); + add_symlink("$tar_dir/$rel_path", "$stage/$rel_path"); my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p); @@ -508,7 +540,7 @@ foreach my $copy_nr ( 1 .. $copies ) { } else { $iso_size = (stat($iso_file))[7]; - print "ISO $iso_file allready exists [$iso_size bytes]\n"; + print "ISO $iso_file already exists [$iso_size bytes]\n"; } print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n"; @@ -528,7 +560,16 @@ foreach my $copy_nr ( 1 .. $copies ) { $sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr); print "Media burn for $disk_name copy $copy_nr recorded\n"; - + + if ($copy_nr >= $copies) { + print STDERR "erasing temporary files, have $copy_nr copies (> $copies)\n"; + foreach my $f (( $xml_file, $iso_file )) { + print STDERR "\t$f "; + unlink $f || die "can't remove $f: $!"; + print STDERR "removed\n"; + } + } + $volume_nr++; }