/[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 253 by dpavlin, Mon Dec 12 13:41:08 2005 UTC revision 254 by dpavlin, Mon Dec 12 16:07:27 2005 UTC
# Line 32  my $tarIncCreate = $path .= 'BackupPC_ta Line 32  my $tarIncCreate = $path .= 'BackupPC_ta
32  die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate);  die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate);
33    
34  my $bin;  my $bin;
35  foreach my $c (qw/gzip/) {  foreach my $c (qw/gzip md5sum/) {
36          $bin->{$c} = which($c) || die "$0 needs $c, install it\n";          $bin->{$c} = which($c) || die "$0 needs $c, install it\n";
37  }  }
38    
# Line 75  sub curr_time { Line 75  sub curr_time {
75  sub tar_check($$$$) {  sub tar_check($$$$) {
76          my ($host,$share,$num,$filename) = @_;          my ($host,$share,$num,$filename) = @_;
77    
         return 1;       # FIXME  
   
78          if ($debug) {          if ($debug) {
79                  print STDERR " {{ CHECK: ${host}:${share}#${num} and $filename";                  print STDERR " {{ CHECK: ${host}:${share}#${num} and $filename";
80          } else {          } else {
81                  print " check";                  print " check";
82          }          }
83    
84          if (-d $filename) {          my @tar_parts;
                 print STDERR ", joining";  
                 tar_join($filename);  
         }  
85    
86          print STDERR ", opening" if ($debug);          if (-d "$tar_dir/$filename") {
87          open(my $fh, "gzip -cd $filename |") or die "can't open $filename: $!";                  print STDERR " multi-part" if ($opt{d});
88          binmode($fh);                  opendir(my $dir, "$tar_dir/$filename") || die "can't readdir $tar_dir/$filename: $!";
89          my $tar = Archive::Tar::Streamed->new($fh);                  @tar_parts = map { my $p = $_; $p =~ s#^#${filename}/#; $p } grep { !/^\./ && !/md5/ && -f "$tar_dir/$filename/$_" } readdir($dir);
90                    closedir($dir);
91            } else {
92                    push @tar_parts, "${filename}.tar.gz";
93            }
94    
         print STDERR ", tar" if ($debug);  
95          my @tar_files;          my @tar_files;
96          while(my $entry = $tar->next) {  
97                  push @tar_files, $entry->name;          print " [parts: ",join(", ", @tar_parts),"]" if ($opt{d});
98    
99            print " reading";
100    
101            foreach my $tarfilename (@tar_parts) {
102    
103                    print STDERR " $tarfilename" if ($debug);
104    
105                    my $path = "$tar_dir/$tarfilename";
106                    my $md5 = $path;
107                    $md5 =~ s/\.tar\.gz$/.md5/ || die "can't create md5 filename from $md5";
108                    if (! -e $md5) {
109                            print ", creating md5";
110                            system( $bin->{md5sum} . " $path > $md5") == 0 or die "can't create md5 $path: $!";
111                    }
112    
113                    open(my $fh, "gzip -cd $tar_dir/$tarfilename |") or die "can't open $tar_dir/$tarfilename: $!";
114                    binmode($fh);
115                    my $tar = Archive::Tar::Streamed->new($fh);
116    
117                    while(my $entry = $tar->next) {
118                            push @tar_files, $entry->name;
119                    }
120          }          }
121    
122          @tar_files = sort @tar_files;          @tar_files = sort @tar_files;
123          print STDERR " ",($#tar_files + 1), " files" if ($debug);          print STDERR " ",($#tar_files + 1), " files" if ($debug);
124    
# Line 177  while (my $row = $sth->fetchrow_hashref) Line 198  while (my $row = $sth->fetchrow_hashref)
198    
199          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});
200    
201          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size && ( $check && tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, "$tar_dir/$tar_file") || 1) ) {          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size && ( $check && tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) || 1) ) {
202                  next;                  next;
203          }          }
204    
# Line 187  while (my $row = $sth->fetchrow_hashref) Line 208  while (my $row = $sth->fetchrow_hashref)
208          my $t = time();          my $t = time();
209    
210          # re-create archive?          # re-create archive?
211          my $cmd = qq{ $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} };          my $cmd = qq{ $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} -f };
212          print STDERR "## $cmd\n" if ($debug);          print STDERR "## $cmd\n" if ($debug);
213    
214          if (system($cmd) != 0) {          if (system($cmd) != 0) {

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

  ViewVC Help
Powered by ViewVC 1.1.26