/[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 293 by dpavlin, Thu Jan 26 00:40:37 2006 UTC revision 329 by dpavlin, Tue Jan 31 22:04:47 2006 UTC
# Line 130  sub get_backup_id($$$) { Line 130  sub get_backup_id($$$) {
130                  FROM backups                  FROM backups
131                  INNER JOIN shares       ON backups.shareID=shares.ID                  INNER JOIN shares       ON backups.shareID=shares.ID
132                  INNER JOIN hosts        ON backups.hostID = hosts.ID                  INNER JOIN hosts        ON backups.hostID = hosts.ID
133                  where hosts.name = ? and shares.name = ? and backups.num = ?                  WHERE hosts.name = ? and shares.name = ? and backups.num = ?
134          });          });
135          $sth->execute($host, $share, $num);          $sth->execute($host, $share, $num);
136          my ($id) = $sth->fetchrow_array;          my ($id) = $sth->fetchrow_array;
# Line 142  sub get_backup_id($$$) { Line 142  sub get_backup_id($$$) {
142          return $id;          return $id;
143  }  }
144    
145    sub backup_inc_deleted($) {
146            my $backup_id = shift;
147            my $sth_inc_deleted = $dbh->prepare(qq{
148                    update backups set
149                            inc_deleted = true
150                    where id = ?
151            });
152            $sth_inc_deleted->execute($backup_id);
153    }
154    
155  sub tar_check($$$$) {  sub tar_check($$$$) {
156          my ($host,$share,$num,$filename) = @_;          my ($host,$share,$num,$filename) = @_;
# Line 274  sub tar_check($$$$) { Line 283  sub tar_check($$$$) {
283                          print ", EMPTY tar\n";                          print ", EMPTY tar\n";
284    
285                          my $backup_id = get_backup_id($host, $share, $num);                          my $backup_id = get_backup_id($host, $share, $num);
286                            backup_inc_deleted( $backup_id );
                         my $sth_inc_deleted = $dbh->prepare(qq{  
                                 update backups set  
                                         inc_deleted = true  
                                 where id = ?  
                         });  
                         $sth_inc_deleted->execute($backup_id);  
287    
288                          $dbh->commit;                          $dbh->commit;
289    
# Line 378  select Line 381  select
381          hosts.name as host,          hosts.name as host,
382          shares.name as share,          shares.name as share,
383          backups.num as num,          backups.num as num,
384            backups.date,
385          inc_size,          inc_size,
386          parts          parts,
387            count(backup_parts.backup_id) as backup_parts
388  from backups  from backups
389          join shares on backups.hostid = shares.hostid          join shares on backups.hostid = shares.hostid
390                  and shares.id = backups.shareid                  and shares.id = backups.shareid
391          join hosts on shares.hostid = hosts.id          join hosts on shares.hostid = hosts.id
392  where not inc_deleted          full outer join backup_parts on backups.id = backup_parts.backup_id
393    where not inc_deleted and backups.size > 0
394    group by backups.id, hosts.name, shares.name, backups.num, backups.date, inc_size, parts, backup_parts.backup_id
395  order by backups.date  order by backups.date
396    
397  } );  } );
# Line 413  while (my $row = $sth->fetchrow_hashref) Line 420  while (my $row = $sth->fetchrow_hashref)
420    
421          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});          print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d});
422    
423          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} >= $size) {          if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} >= $size && $row->{parts} == $row->{backup_parts}) {
424                  if ($check) {                  if ($check) {
425                          tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) && next;                          tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) && next;
426                  } else {                  } else {
# Line 421  while (my $row = $sth->fetchrow_hashref) Line 428  while (my $row = $sth->fetchrow_hashref)
428                  }                  }
429          }          }
430    
431          print curr_time, " creating $curr_backup/$num_backups ", $row->{'host'}, ":", $row->{'share'}, " #", $row->{'num'}, " -> $tar_file";          print curr_time, " creating $curr_backup/$num_backups ", $row->{host}, ":", $row->{share}, " #", $row->{num},
432                    " ", strftime('%Y-%m-%d', localtime($row->{date})), " -> $tar_file";
433    
434          my $t = time();          my $t = time();
435    
436          # re-create archive?          # re-create archive?
437          my $cmd = qq{ $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} -f };          my $cmd = qq[ $tarIncCreate -h "$row->{host}" -s "$row->{share}" -n $row->{num} -f ];
438          print STDERR "## $cmd\n" if ($debug);          print STDERR "## $cmd\n" if ($debug);
439    
440          if (system($cmd) != 0) {          if (system($cmd) != 0) {
441                  print STDERR " FAILED";                  print STDERR " FAILED, marking this backup deleted";
442                    backup_inc_deleted( $row->{backup_id} );
443          }          }
444    
445          print ", dur: ",fmt_time(time() - $t), "\n";          print ", dur: ",fmt_time(time() - $t), "\n";

Legend:
Removed from v.293  
changed lines
  Added in v.329

  ViewVC Help
Powered by ViewVC 1.1.26