- notices removed from sql
authoriklaric <iklaric@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Mon, 7 May 2007 08:48:47 +0000 (08:48 +0000)
committeriklaric <iklaric@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Mon, 7 May 2007 08:48:47 +0000 (08:48 +0000)
- burnArchiveCLI now tries to recreate missing tars using tarIncCreate

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@371 8392b6e1-25fa-0310-8288-cc32f8e212ea

bin/BackupPC_burnArchiveCLI
bin/BackupPC_incPartsUpdate
sql/09_backup_parts_trigger.sql

index f8845d4..826a87f 100755 (executable)
@@ -1,7 +1,7 @@
-#!/usr/bin/perl
+#!/usr/local/bin/perl
 
 use strict;
-use lib "__INSTALLDIR__/lib";
+use lib "/data/backuppc-agi//lib";
 
 use DBI;
 use BackupPC::Lib;
@@ -12,7 +12,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 +33,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 +397,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!";
@@ -469,8 +475,24 @@ 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 $cmd = $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);
@@ -514,6 +536,8 @@ foreach my $copy_nr ( 1 .. $copies ) {
 
                        print "\nREADY TO BURN MEDIA $disk_name copy $copy_nr\n\nPlease insert blank media and press ENTER\n\n";
 
+                       die("debugging only!");
+
                        system($bin->{'eject'}.' '.$eject_opts) == 0 or skip "can't run eject: $?";
 
                        my $wait = <STDIN>;
index 72a5ba0..690795a 100755 (executable)
@@ -418,7 +418,7 @@ while (my $row = $sth->fetchrow_hashref) {
        # this will return -1 if file doesn't exist
        my $size = BackupPC::SearchLib::get_tgz_size_by_name($tar_file);
 
-       print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});
+       print "# host: ".${row->{host}}.", share: ".$row->{'share'}.", backup_num:".$row->{num}." size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});
 
        if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} >= $size && $row->{parts} == $row->{backup_parts}) {
                if ($check) {
index c48163c..6c72fd4 100644 (file)
@@ -37,20 +37,19 @@ declare
        calc_part       integer;
 begin
        if (TG_OP = ''INSERT'') then
-               raise notice ''trigger: % backup_id %'', TG_OP, new.backup_id;
+               -- raise notice ''trigger: % backup_id %'', TG_OP, new.backup_id;
                b_id = new.backup_id;
                my_part_nr = new.part_nr;
                execute ''update backups set parts = parts + 1 where id = '' || b_id;
        elsif (TG_OP = ''DELETE'') then
-               raise notice ''trigger: % backup_id %, old.part_nr %'', TG_OP, old.backup_id, old.part_nr;
+               -- raise notice ''trigger: % backup_id %, old.part_nr %'', TG_OP, old.backup_id, old.part_nr;
                b_id = old.backup_id;
                my_part_nr = old.part_nr - 1;
                execute ''update backups set parts = parts - 1 where id = '' || b_id;
        end if;
        calc_part := (select count(part_nr) from backup_parts where backup_id = b_id);
        if ( my_part_nr != calc_part ) then 
-       raise exception ''Update of backup_parts with backup_id % aborted, requested part_nr is % and calulated next is %'', b_id, my_part_nr, calc_part;
-       
+               raise exception ''Update of backup_parts with backup_id % aborted, requested part_nr is % and calulated next is %'', b_id, my_part_nr, calc_part;
        end if;
        return null;
 end;