/[BackupPC]/trunk/bin/BackupPC_burnArchiveCLI
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_burnArchiveCLI

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 338 by dpavlin, Wed Mar 1 13:24:36 2006 UTC revision 371 by iklaric, Mon May 7 08:48:47 2007 UTC
# Line 1  Line 1 
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;
# Line 12  use Term::Menus; Line 12  use Term::Menus;
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;
# Line 33  $conf_bin->{'eject'} = $Conf{ejectBin} | Line 33  $conf_bin->{'eject'} = $Conf{ejectBin} |
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/) {
# Line 394  foreach my $copy_nr ( 1 .. $copies ) { Line 397  foreach my $copy_nr ( 1 .. $copies ) {
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!";
# Line 406  foreach my $copy_nr ( 1 .. $copies ) { Line 412  foreach my $copy_nr ( 1 .. $copies ) {
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    
# Line 468  foreach my $copy_nr ( 1 .. $copies ) { Line 475  foreach my $copy_nr ( 1 .. $copies ) {
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);
# Line 513  foreach my $copy_nr ( 1 .. $copies ) { Line 536  foreach my $copy_nr ( 1 .. $copies ) {
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>;
# Line 528  foreach my $copy_nr ( 1 .. $copies ) { Line 553  foreach my $copy_nr ( 1 .. $copies ) {
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    

Legend:
Removed from v.338  
changed lines
  Added in v.371

  ViewVC Help
Powered by ViewVC 1.1.26