/[BackupPC]/trunk/bin/BackupPC_incPartsUpdate
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_incPartsUpdate

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

revision 254 by dpavlin, Mon Dec 12 16:07:27 2005 UTC revision 256 by dpavlin, Mon Dec 12 20:59:53 2005 UTC
# Line 22  my %Conf = $bpc->Conf(); Line 22  my %Conf = $bpc->Conf();
22  use BackupPC::SearchLib;  use BackupPC::SearchLib;
23  %BackupPC::SearchLib::Conf = %Conf;  %BackupPC::SearchLib::Conf = %Conf;
24    
 # cludge: minimum .tar.gz size  
 my $MIN_TAR_SIZE = 80;  
   
25  my $path = abs_path($0);  my $path = abs_path($0);
26  $path =~ s#/[^/]+$#/#;  $path =~ s#/[^/]+$#/#;
27  my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';  my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';
# Line 92  sub tar_check($$$$) { Line 89  sub tar_check($$$$) {
89                  push @tar_parts, "${filename}.tar.gz";                  push @tar_parts, "${filename}.tar.gz";
90          }          }
91    
         my @tar_files;  
   
92          print " [parts: ",join(", ", @tar_parts),"]" if ($opt{d});          print " [parts: ",join(", ", @tar_parts),"]" if ($opt{d});
93    
94            my $same = 1;
95            my @tar_files;
96    
97          print " reading";          print " reading";
98    
99          foreach my $tarfilename (@tar_parts) {          foreach my $tarfilename (@tar_parts) {
# Line 114  sub tar_check($$$$) { Line 112  sub tar_check($$$$) {
112                  binmode($fh);                  binmode($fh);
113                  my $tar = Archive::Tar::Streamed->new($fh);                  my $tar = Archive::Tar::Streamed->new($fh);
114    
115                    my $total_size = 0;
116    
117                  while(my $entry = $tar->next) {                  while(my $entry = $tar->next) {
118                          push @tar_files, $entry->name;                          push @tar_files, $entry->name;
119                            $total_size += $entry->size;
120                    }
121    
122                    if ($total_size > $Conf{MaxArchiveFileSize}) {
123                            print STDERR " part too big $total_size > $Conf{MaxArchiveFileSize} }}" if ($debug);
124                            $same = 0;
125                            last;
126                    } elsif ($total_size > $Conf{MaxArchiveSize}) {
127                            print STDERR " part bigger than media $total_size > $Conf{MaxArchiveSize} }}" if ($debug);
128                            $same = 0;
129                            last;
130                  }                  }
131          }          }
132    
133            # short-cut and exit;
134            return $same unless($same);
135    
136          @tar_files = sort @tar_files;          @tar_files = sort @tar_files;
137          print STDERR " ",($#tar_files + 1), " files" if ($debug);          print STDERR " ",($#tar_files + 1), " files" if ($debug);
138    
# Line 145  sub tar_check($$$$) { Line 159  sub tar_check($$$$) {
159    
160          @db_files = sort @db_files;          @db_files = sort @db_files;
161    
         my $same = 1;  
162          if ($#tar_files != $#db_files) {          if ($#tar_files != $#db_files) {
163                  $same = 0;                  $same = 0;
164                  print STDERR " NUMBER" if ($debug);                  print STDERR " NUMBER" if ($debug);
# Line 198  while (my $row = $sth->fetchrow_hashref) Line 211  while (my $row = $sth->fetchrow_hashref)
211    
212          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});
213    
214          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size && ( $check && tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) || 1) ) {          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size) {
215                  next;                  if ($check) {
216                            tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) && next;
217                    } else {
218                            next;
219                    }
220          }          }
221    
222          print curr_time, " $curr_backup/$num_backups ", $row->{'host'}, ":", $row->{'share'}, " #", $row->{'num'}, " -> $tar_file";          print curr_time, " $curr_backup/$num_backups ", $row->{'host'}, ":", $row->{'share'}, " #", $row->{'num'}, " -> $tar_file";

Legend:
Removed from v.254  
changed lines
  Added in v.256

  ViewVC Help
Powered by ViewVC 1.1.26