/[BackupPC]/trunk/bin/BackupPC_updatedb
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_updatedb

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

revision 66 by dpavlin, Mon Aug 22 00:09:59 2005 UTC revision 74 by dpavlin, Fri Aug 26 17:18:27 2005 UTC
# Line 223  foreach my $host_key (keys %{$hosts}) { Line 223  foreach my $host_key (keys %{$hosts}) {
223                  $hostID = $dbh->last_insert_id(undef,undef,'hosts',undef);                  $hostID = $dbh->last_insert_id(undef,undef,'hosts',undef);
224          }          }
225    
226          print("host ".$hosts->{$host_key}->{'host'}.": ");          print "host ".$hosts->{$host_key}->{'host'}.": ";
227    
228          # get backups for a host          # get backups for a host
229          my @backups = $bpc->BackupInfoRead($hostname);          my @backups = $bpc->BackupInfoRead($hostname);
230          print scalar @backups, " increments\n";          my $incs = scalar @backups;
231            print  "$incs increments\n";
232    
233          my $inc_nr = 0;          my $inc_nr = 0;
234            $beenThere = {};
235    
236          foreach my $backup (@backups) {          foreach my $backup (@backups) {
237    
# Line 239  foreach my $host_key (keys %{$hosts}) { Line 241  foreach my $host_key (keys %{$hosts}) {
241                  my $backupNum = $backup->{'num'};                  my $backupNum = $backup->{'num'};
242                  my @backupShares = ();                  my @backupShares = ();
243    
244                  print $hosts->{$host_key}->{'host'},                  printf("%-10s %2d/%-2d #%-2d %s %5s/%5s files (date: %s dur: %s)\n",
245                          "\t#$backupNum\t", $backup->{type} || '?', " ",                          $hosts->{$host_key}->{'host'},
246                          $backup->{nFilesNew} || '?', "/", $backup->{nFiles} || '?',                          $inc_nr, $incs, $backupNum,
247                          " files (date: ",                          $backup->{type} || '?',
248                            $backup->{nFilesNew} || '?', $backup->{nFiles} || '?',
249                          strftime($t_fmt,localtime($backup->{startTime})),                          strftime($t_fmt,localtime($backup->{startTime})),
250                          " dur: ",                          fmt_time($backup->{endTime} - $backup->{startTime})
251                          fmt_time($backup->{endTime} - $backup->{startTime}),                  );
                         ")\n";  
252    
253                  my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1);                  my $files = BackupPC::View->new($bpc, $hostname, \@backups, 1);
254                  foreach my $share ($files->shareList($backupNum)) {                  foreach my $share ($files->shareList($backupNum)) {
# Line 328  sub found_in_db { Line 330  sub found_in_db {
330          my @data = @_;          my @data = @_;
331          shift @data;          shift @data;
332    
333          my ($key, $shareID,undef,$name,$path,undef,$date,undef,$size) = @_;          my ($key, $shareID,undef,$name,$path,$date,undef,$size) = @_;
334    
335          return $beenThere->{$key} if (defined($beenThere->{$key}));          return $beenThere->{$key} if (defined($beenThere->{$key}));
336    
# Line 336  sub found_in_db { Line 338  sub found_in_db {
338                  SELECT 1 FROM files                  SELECT 1 FROM files
339                  WHERE shareID = ? and                  WHERE shareID = ? and
340                          path = ? and                          path = ? and
                         name = ? and  
341                          date = ? and                          date = ? and
342                          size = ?                          size = ?
343                    LIMIT 1
344          });          });
345    
346          my @param = ($shareID,$path,$name,$date,$size);          my @param = ($shareID,$path,$date,$size);
347          $sth->{file_in_db}->execute(@param);          $sth->{file_in_db}->execute(@param);
348          my $rows = $sth->{file_in_db}->rows;          my $rows = $sth->{file_in_db}->rows;
349          print STDERR "## found_in_db ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);          print STDERR "## found_in_db($shareID,$path,$date,$size) ",( $rows ? '+' : '-' ), join(" ",@param), "\n" if ($debug >= 3);
350    
351          $beenThere->{$key}++;          $beenThere->{$key}++;
352    
# Line 391  sub recurseDir($$$$$$$$) { Line 393  sub recurseDir($$$$$$$$) {
393                                  $filesInBackup->{$path_key}->{'size'}                                  $filesInBackup->{$path_key}->{'size'}
394                          ));                          ));
395    
396                            my $found;
397                          if (! defined($beenThere->{$key}) && ! found_in_db($key, @data)) {                          if (! defined($beenThere->{$key}) && ! ($found = found_in_db($key, @data)) ) {
398                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);                                  print STDERR "# key: $key [", $beenThere->{$key},"]" if ($debug >= 2);
399    
400                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {                                  if ($filesInBackup->{$path_key}->{'type'} == BPC_FTYPE_DIR) {
401                                          $new_dirs++;                                          $new_dirs++ unless ($found);
402                                          print STDERR " dir\n" if ($debug >= 2);                                          print STDERR " dir\n" if ($debug >= 2);
403                                  } else {                                  } else {
404                                          $new_files++;                                          $new_files++ unless ($found);
405                                          print STDERR " file\n" if ($debug >= 2);                                          print STDERR " file\n" if ($debug >= 2);
406                                  }                                  }
407                                  $size += $filesInBackup->{$path_key}->{'size'} || 0;                                  $size += $filesInBackup->{$path_key}->{'size'} || 0;

Legend:
Removed from v.66  
changed lines
  Added in v.74

  ViewVC Help
Powered by ViewVC 1.1.26