X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_ASA_BurnArchiveMedia;h=2643918d4d94a4c5959c10d422b43ed65f82e875;hp=f75be3417f8efe418519e17d6a43291814b51b9c;hb=a63fb961f9a5ea6a067b8e3b0f243f00858429c6;hpb=03405f166a7ef2ced8bf2829d08263e7bd9c922f diff --git a/bin/BackupPC_ASA_BurnArchiveMedia b/bin/BackupPC_ASA_BurnArchiveMedia index f75be34..2643918 100755 --- a/bin/BackupPC_ASA_BurnArchiveMedia +++ b/bin/BackupPC_ASA_BurnArchiveMedia @@ -15,7 +15,7 @@ use File::Path; use Cwd qw/abs_path/; use Data::Dumper; -my $debug = 0; +my $debug = $ENV{DEBUG} || 1; # set this to 1 to prompt for DVD removal for each selected item. my $prompt_for_delete = shift @ARGV; $|=1; @@ -112,22 +112,16 @@ sub dumpArchive2XML($$$) my $backups_sql = q{ SELECT - backups.id AS backup_id, - hosts.name AS host, - backups.num AS num, - backups.date AS date, - shares.name AS share, - backups.size AS backup_size, - backups.inc_size AS compress_size - FROM backups - JOIN backup_parts ON backup_parts.backup_id = backups.id - JOIN archive_parts ON archive_parts.backup_id = backups.id - JOIN hosts ON hosts.id = backups.hostid - JOIN shares ON shares.id = backups.shareid - WHERE archive_parts.backup_id = backups.id - AND archive_parts.archive_id = ? - ORDER BY - hosts.name, shares.name, backups.num + backup_id, + backup_part_id, + host, + num, + date, + share, + size + FROM archive_backup_parts + WHERE archive_id = ? + ORDER BY backup_part_id }; my $sth = $dbh->prepare("SELECT dvd_nr, total_size, note, username, date, id FROM archive WHERE dvd_nr=?"); @@ -318,36 +312,22 @@ sub delete_dvd($) { my $sth_archive_backup_parts = $dbh->prepare( qq{ SELECT - backup_parts.backup_id, + backup_id, archive_id, - hosts.name as host, - shares.name as share, - backups.num as num, - backups.parts as parts, - backup_parts.part_nr as part_nr, - backup_parts.size as part_size, - backup_parts.md5 as md5, - backup_parts.items, - backup_parts.filename - FROM backup_parts - JOIN archive_parts ON backup_parts.id = backup_part_id - JOIN archive ON archive_id = archive.id - JOIN backups ON backup_id = backups.id - JOIN hosts ON hostid = hosts.id - JOIN shares ON shareid = shares.id - WHERE archive.dvd_nr = ? + host, + share, + num, + part_nr, + parts, + size, + md5, + items, + filename + FROM archive_backup_parts + WHERE dvd_nr = ? ORDER BY backup_id, part_nr }); -my $sth_archive_backup_check = $dbh->prepare( qq{ - SELECT - count(*) - FROM archive - JOIN archive_parts ON archive_id = archive.id - JOIN backup_parts ON backup_part_id = backup_parts.id - WHERE dvd_nr = ? -}); - my $sth_archive_burned = $dbh->prepare( qq{ insert into archive_burned (archive_id, iso_size, part, copy) @@ -372,18 +352,6 @@ foreach my $copy_nr ( 1 .. $copies ) { $sth_archive_backup_parts->execute($dvd_nr); - $sth_archive_backup_check->execute($dvd_nr); - - my ($parts_nr, $check_nr) = ($sth_archive_backup_parts->rows, $sth_archive_backup_check->fetchrow_array); - - if ($parts_nr != $check_nr) { - warn "ERROR: DVD #$dvd_nr is still not inconsistent state. Some backup parts are ", - ($parts_nr < $check_nr) ? "missing ($parts_nr < $check_nr)" : "extra ($parts_nr > $check_nr)", - " you should re-create this DVD after BackupPC_incPartsUpdate finish\n"; - delete_dvd( $dvd_nr ); - next; - } - if ($sth_archive_backup_parts->rows == 0) { warn "ERROR: no backup parts found for $dvd_nr. You should re-create that DVD.\n"; next if delete_dvd( $dvd_nr ); @@ -399,12 +367,12 @@ foreach my $copy_nr ( 1 .. $copies ) { my $max_archive_size = $Conf{ArchiveMediaSize} || die "no ArchiveMediaSize"; while (my $row = $sth_archive_backup_parts->fetchrow_hashref) { - if (($v->{size} || 0) + $row->{part_size} > $max_archive_size) { + if (($v->{size} || 0) + $row->{size} > $max_archive_size) { push @volumes, $v; $v = {}; } - $v->{size} += $row->{part_size}; - $v_size += $row->{part_size}; + $v->{size} += $row->{size}; + $v_size += $row->{size}; # this part my $p; @@ -416,7 +384,7 @@ foreach my $copy_nr ( 1 .. $copies ) { } push @volumes, $v if ($v); - #warn "# volumes: ",Dumper(\@volumes)," total size: ", fmt_mb($v_size), "\n"; + warn "# volumes: ",Dumper(\@volumes)," total size: ", fmt_mb($v_size), "\n" if $debug; # check available disk space @@ -562,7 +530,6 @@ print "Recoding finished, exiting...\n"; $sth->finish; $sth_archive_backup_parts->finish; $sth_archive_burned->finish; -$sth_archive_backup_check->finish; $sth_archive_burned->finish; $dbh->disconnect;