/[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 172 by dpavlin, Tue Oct 11 16:00:02 2005 UTC revision 194 by dpavlin, Thu Oct 13 17:11:59 2005 UTC
# Line 63  select Line 63  select
63          backups.id as backup_id,          backups.id as backup_id,
64          hosts.name as host,          hosts.name as host,
65          shares.name as share,          shares.name as share,
66          backups.num as num          backups.num as num,
67            inc_size
68  from backups  from backups
69          join shares on backups.hostid = shares.hostid          join shares on backups.hostid = shares.hostid
70                  and shares.id = backups.shareid                  and shares.id = backups.shareid
71          join hosts on shares.hostid = hosts.id          join hosts on shares.hostid = hosts.id
72  where inc_size < 0 and not inc_deleted  where not inc_deleted
73  order by backups.date  order by backups.date
74    
75  } );  } );
# Line 82  my $sth_inc_deleted = $dbh->prepare(qq{ Line 83  my $sth_inc_deleted = $dbh->prepare(qq{
83    
84  while (my $row = $sth->fetchrow_hashref) {  while (my $row = $sth->fetchrow_hashref) {
85          my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});          my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});
86          print curr_time, sprintf(" %s:%s %-3d ", $row->{'host'}, $row->{'share'}, $row->{'num'}), " -> $tar_file ";  
87            # this will return -1 if file doesn't exist
88            my $size = BackupPC::SearchLib::get_tgz_size_by_name($tar_file);
89    
90            print curr_time, " ", $row->{'host'}, ":", $row->{'share'}, " #", $row->{'num'}, " -> $tar_file";
91    
92          my $t = time();          my $t = time();
93    
94          my $cmd = qq{$tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};          # re-create archive?
95          print STDERR "## $cmd\n" if ($debug);          if ($row->{'inc_size'} == -1 || $size == -1 || $row->{'inc_size'} != $size) {
96                    my $cmd = qq{$tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};
97                    print STDERR "## $cmd\n" if ($debug);
98    
99                    system($cmd) == 0 or die "failed: $?";
100            
101                    $size = (stat( "$tar_dir/$tar_file" ))[7];
102            }
103    
104          system($cmd) == 0 or die "failed: $?";          if ($size > 45) {
105    
106          my $size = (stat( "$tar_dir/$tar_file" ))[7];                  my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar";
107    
108          print " dur: ",fmt_time(time() - $t)," $size bytes";                  if ($size > $max_size && ! -d "$tar_dir/$tar_file") {
109                            print " split";
110                            my $in = my $out = "$tar_dir/$tar_file";
111                            $out .= '.tmp';
112                            rename $in, $out || die "can't rename $in: $!";
113                            mkdir $in || die "can't mkdir $in: $!";
114                            system("split -d -b $max_size $out $in/part") == 0 or die "can't split $out: $!";
115                            unlink $out || die "can't unlink $out: $!";
116                    }
117    
         if ($size > 45) {  
118                  $sth_inc_size->execute($size, $row->{'backup_id'});                  $sth_inc_size->execute($size, $row->{'backup_id'});
119                  $sth_inc_deleted->execute(0, $row->{'backup_id'});                  $sth_inc_deleted->execute(0, $row->{'backup_id'});
120    
121                    printf(" %1.2f MB", ($size / 1024 / 1024));
122    
123          } else {          } else {
124                  $sth_inc_deleted->execute(1, $row->{'backup_id'});                  $sth_inc_deleted->execute(1, $row->{'backup_id'});
125                  unlink "$tar_dir/$tar_file" || die "can't delete $tar_dir/$tar_file: $!\n";                  unlink "$tar_dir/$tar_file" || die "can't delete $tar_dir/$tar_file: $!\n";
126                  print " EMPTY";                  print " EMPTY";
127          }          }
128          print "\n";          print ", dur: ",fmt_time(time() - $t), "\n";
129    
130          $dbh->commit;          $dbh->commit;
131    

Legend:
Removed from v.172  
changed lines
  Added in v.194

  ViewVC Help
Powered by ViewVC 1.1.26