X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=bin%2FBackupPC_burnArchiveCLI;h=4c029c1308a07cc3f1bae79ed6282fc182e3717a;hb=cc69bd9efd1cfb510eeb3739ff47436a3a6d1f09;hp=6ec15187bfe78050abcb93720927ad84808aae30;hpb=c664562640cb5d9d8c6ade63d14108fdf7364e4d;p=BackupPC.git diff --git a/bin/BackupPC_burnArchiveCLI b/bin/BackupPC_burnArchiveCLI index 6ec1518..4c029c1 100755 --- a/bin/BackupPC_burnArchiveCLI +++ b/bin/BackupPC_burnArchiveCLI @@ -15,6 +15,8 @@ use File::Path; use Data::Dumper; my $debug = 0; +# set this to 1 to prompt for DVD removal for each selected item. +my $prompt_for_delete = 0; $|=1; # don't check for user @@ -253,6 +255,39 @@ sub add_symlink($$) { symlink $from, $to || skip("can't symlink $from to $to: $!"); } +sub delete_dvd($) { + my $dvd_nr = shift || return; + + print "Do you want to delete DVD #$dvd_nr now? [NO/yes]: "; + my $ok = ; + chomp($ok); + if (lc($ok) eq 'yes') { + print "Deleting DVD #$dvd_nr from database...\n"; + + $dbh->begin_work; + + my $sth_delete_dvd = $dbh->prepare( qq{ + delete from archive where dvd_nr = ? + } ); + $sth_delete_dvd->execute( $dvd_nr ); + $dbh->do( qq{ + select setval('dvd_nr', (select max(dvd_nr) from archive), true) + } ); + + # remove files for this DVD + map { + print "\tremoving $_\n"; + unlink($_) || die "can't rm $_: $!"; + } glob ( "/$iso_dir/$dvd_nr.*" ); + + $dbh->commit; + + return 1; + } else { + return 0; + } +} + my $sth_archive_backup_parts = $dbh->prepare( qq{ select archive_backup.backup_id, @@ -295,6 +330,15 @@ foreach my $arc (@archives_to_burn) { $sth_archive_backup_parts->execute($dvd_nr); + if ($sth_archive_backup_parts->rows == 0) { + warn "ERROR: no backup parts found for $dvd_nr. You should re-create that DVD.\n"; + delete_dvd( $dvd_nr ); + } + + if ($prompt_for_delete) { + next if delete_dvd( $dvd_nr ); + } + my @volumes; my $v; # emtpy volume my $v_size = 0; @@ -317,6 +361,8 @@ foreach my $arc (@archives_to_burn) { } push @volumes, $v if ($v); + #warn "# volumes: ",Dumper(\@volumes),"\n"; + my $volumes = $#volumes + 1; my $volume_nr = 1; @@ -327,7 +373,7 @@ foreach my $arc (@archives_to_burn) { my $iso_size = 0; my $disk_name = $dvd_nr; # suffix added to multi-volume archives - my $volume_suffix = $dvd_nr; + my $volume_suffix = ''; if ($volumes > 1) { $volume_suffix = '_' . $volume_nr;