/[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 373 by iklaric, Mon May 7 13:20:38 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                                                    my $currUser = getlogin();
485                                                    my $otherUser = "";
486                                                    if ($currUser eq "agi") {
487                                                            $otherUser = "backuppc-agi";
488                                                    } elsif ($currUser eq "qc") {
489                                                            $otherUser = "backuppc-qc";
490                                                    }
491                                                    if ($otherUser ne "") {
492                                                            my $cmd = "sudo -u $otherUser ".$tarIncCreate. " -h $host -s $share -n $dump";
493                                                            print "$cmd ";
494                                                            if (system($cmd) != 0) {
495                                                                    print " FAILED.\n";
496                                                            } else {
497                                                                    print " done.\n";
498                                                    }
499                                            }      
500                                            }
501    
502                                            skip "can't find increment $rel_path, recreateing obviously did not work: $!" unless (-r "$tar_dir/$rel_path");
503                                            
504                                          add_symlink("$tar_dir/$rel_path", "$stage/$rel_path");                                          add_symlink("$tar_dir/$rel_path", "$stage/$rel_path");
505    
506                                          my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p);                                          my $md5sum = $p->{md5} || die "no md5 in part ", Dumper($p);
# Line 508  foreach my $copy_nr ( 1 .. $copies ) { Line 539  foreach my $copy_nr ( 1 .. $copies ) {
539    
540                          } else {                          } else {
541                                  $iso_size = (stat($iso_file))[7];                                  $iso_size = (stat($iso_file))[7];
542                                  print "ISO $iso_file allready exists [$iso_size bytes]\n";                                  print "ISO $iso_file already exists [$iso_size bytes]\n";
543                          }                          }
544    
545                          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";
# Line 528  foreach my $copy_nr ( 1 .. $copies ) { Line 559  foreach my $copy_nr ( 1 .. $copies ) {
559                          $sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr);                          $sth_archive_burned->execute($dvd_nr, $iso_size, $volume_nr, $copy_nr);
560    
561                          print "Media burn for $disk_name copy $copy_nr recorded\n";                          print "Media burn for $disk_name copy $copy_nr recorded\n";
562                    
563                            if ($copy_nr >= $copies) {
564                                    print STDERR "erasing temporary files, have $copy_nr copies (> $copies)\n";
565                                    foreach my $f (( $xml_file, $iso_file )) {
566                                            print STDERR "\t$f ";
567                                            unlink $f || die "can't remove $f: $!";
568                                            print STDERR "removed\n";
569                                    }
570                            }
571    
572                          $volume_nr++;                          $volume_nr++;
573                  }                  }
574    

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

  ViewVC Help
Powered by ViewVC 1.1.26