/[BackupPC]/trunk/bin/BackupPC_burnArchiveCLI
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_burnArchiveCLI

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

revision 291 by dpavlin, Sun Jan 15 14:50:39 2006 UTC revision 292 by dpavlin, Thu Jan 26 00:39:47 2006 UTC
# Line 16  use Data::Dumper; Line 16  use Data::Dumper;
16    
17  my $debug = 0;  my $debug = 0;
18  # set this to 1 to prompt for DVD removal for each selected item.  # set this to 1 to prompt for DVD removal for each selected item.
19  my $prompt_for_delete = 0;  my $prompt_for_delete = shift @ARGV;
20  $|=1;  $|=1;
21    
22  # don't check for user  # don't check for user
# Line 111  sub dumpArchive2XML($$$) Line 111  sub dumpArchive2XML($$$)
111                          AND hosts.id=backups.hostid                          AND hosts.id=backups.hostid
112                          AND shares.id=backups.shareid                          AND shares.id=backups.shareid
113                          AND archive_backup.archive_id = ?                          AND archive_backup.archive_id = ?
114                    ORDER BY
115                            hosts.name, shares.name, backups.num
116          };          };
117    
118          my $sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date,id FROM archive WHERE dvd_nr=?");          my $sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date,id FROM archive WHERE dvd_nr=?");
# Line 164  sub dumpArchive2XML($$$) Line 166  sub dumpArchive2XML($$$)
166                          $writer->endTag("file");                          $writer->endTag("file");
167                  }                  }
168                  $writer->endTag("backup");                  $writer->endTag("backup");
169          }                }
170                                                    
171          $writer->endTag("archive");          $writer->endTag("archive");
172          $writer->end();          $writer->end();
# Line 310  my $sth_archive_backup_parts = $dbh->pre Line 312  my $sth_archive_backup_parts = $dbh->pre
312          order by archive_backup.backup_id, backup_parts.part_nr          order by archive_backup.backup_id, backup_parts.part_nr
313  });  });
314    
315    my $sth_archive_backup_check = $dbh->prepare( qq{
316                    SELECT
317                            count(backups.id)
318                    FROM backups
319                    JOIN archive_backup on archive_backup.backup_id = backups.id
320                    JOIN archive on archive_id = archive.id
321                    WHERE dvd_nr = ?
322    });
323    
324  my $sth_archive_burned = $dbh->prepare( qq{  my $sth_archive_burned = $dbh->prepare( qq{
325          insert into archive_burned          insert into archive_burned
326                  (archive_id, iso_size, part, copy)                  (archive_id, iso_size, part, copy)
# Line 330  foreach my $arc (@archives_to_burn) { Line 341  foreach my $arc (@archives_to_burn) {
341    
342          $sth_archive_backup_parts->execute($dvd_nr);          $sth_archive_backup_parts->execute($dvd_nr);
343    
344            $sth_archive_backup_check->execute($dvd_nr);
345    
346            my ($parts_nr, $check_nr) = ($sth_archive_backup_parts->rows, $sth_archive_backup_check->fetchrow_array);
347    
348            if ($parts_nr != $check_nr) {
349                    warn "ERROR: DVD #$dvd_nr is still not in consistent state. Some backup parts are ",
350                            ($parts_nr < $check_nr) ? "missing ($parts_nr < $check_nr)" : "extra ($parts_nr > $check_nr)",
351                            " you should re-create this DVD after BackupPC_incPartsUpdate finish\n";
352                    next if delete_dvd( $dvd_nr );
353            }
354    
355          if ($sth_archive_backup_parts->rows == 0) {          if ($sth_archive_backup_parts->rows == 0) {
356                  warn "ERROR: no backup parts found for $dvd_nr. You should re-create that DVD.\n";                  warn "ERROR: no backup parts found for $dvd_nr. You should re-create that DVD.\n";
357                  delete_dvd( $dvd_nr );                  next if delete_dvd( $dvd_nr );
358          }          }
359    
360          if ($prompt_for_delete) {          if ($prompt_for_delete) {

Legend:
Removed from v.291  
changed lines
  Added in v.292

  ViewVC Help
Powered by ViewVC 1.1.26