r10295@llin: dpavlin | 2006-03-01 14:23:33 +0100
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Wed, 1 Mar 2006 13:24:36 +0000 (13:24 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Wed, 1 Mar 2006 13:24:36 +0000 (13:24 +0000)
 check disk space before creating ISO image, and abort if not enough free space is available

git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@338 8392b6e1-25fa-0310-8288-cc32f8e212ea

BUGS
bin/BackupPC_burnArchiveCLI
doc/Search.pod

diff --git a/BUGS b/BUGS
index bdacd18..367cef6 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -23,7 +23,7 @@
 + covert size options in configuration files to bytes
 
 - automatically expire iso images which are burned BurnMultipleCopies times
-- warn about disk usage in BackupPC_burnArchiveCLI before creating new iso image
++ warn about disk usage in BackupPC_burnArchiveCLI before creating new iso image
 + burn two copies of three part increment as 1 2 3 1 2 3 and not 1 1 2 2 3 3
 - script to recover host pool from increments only
 
index b17f5e0..18013c2 100755 (executable)
@@ -11,6 +11,7 @@ use POSIX qw/strftime/;
 use Term::Menus;
 use File::Which;
 use File::Path;
+use Filesys::Df;
 
 use Data::Dumper;
 
@@ -193,23 +194,29 @@ order by date asc
 
 $sth->execute();
 
+sub fmt_mb($) {
+       my $s = shift;
+       die "missing size" unless defined($s);
+       $s /= (1024*1024);
+       return sprintf("%.2f Mb", $s);
+}
+
 sub fmt_archive($) {
        my $row = shift || die;
 
        $row->{'date'} =~ s/\.\d+$//;
        $row->{'copies'} =~ s/^\s*0+\s*$/no/;
-       $row->{'total_size'} /= (1024*1024);
 
        my $copies = 'copies';
        $copies = 'copy' if ($row->{'copies'} == 1);
 
        return
-               sprintf("%d by %s on %s, %s %s [%.2f Mb]",
+               sprintf("%d by %s on %s, %s %s [%s]",
                        $row->{'dvd_nr'},
                        $row->{'username'},
                        $row->{'date'},
                        $row->{'copies'}, $copies,
-                       $row->{'total_size'},
+                       fmt_mb($row->{'total_size'}),
                );
 }
 
@@ -382,6 +389,8 @@ foreach my $copy_nr ( 1 .. $copies ) {
                                $v = {};
                        }
                        $v->{size} += $row->{part_size};
+                       $v_size += $row->{part_size};
+
                        # this part
                        my $p = {
                                filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}),
@@ -393,7 +402,15 @@ foreach my $copy_nr ( 1 .. $copies ) {
                }
                push @volumes, $v if ($v);
 
-               #warn "# volumes: ",Dumper(\@volumes),"\n";
+               #warn "# volumes: ",Dumper(\@volumes)," total size: ", fmt_mb($v_size), "\n";
+
+               # check available disk space
+
+               my $df = df($iso_dir);
+               if ($df < $v_size) {
+                       warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( df($iso_dir) ), "]\n";
+                       next;
+               }
 
                my $volumes = $#volumes + 1;
                my $volume_nr = 1;
@@ -412,7 +429,7 @@ foreach my $copy_nr ( 1 .. $copies ) {
                                $disk_name .= ' ' . $volume_nr . '/' . $volumes;
                        }
 
-                       print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes\n";
+                       print "Processing DVD #$dvd_nr, volume $volume_nr/$volumes [", fmt_mb($v->{size}), "]\n";
 
                        my $iso_file = my $xml_file = my $stage =
                                "${iso_dir}/${dvd_nr}";
index 719fa8d..2e72e40 100644 (file)
@@ -90,6 +90,7 @@ You will also need a few additional cpan modules
 =item XML::Writer
 =item Algorithm::Diff
 =item Archive::Tar::Stream
+=item Filesys::Df
 
 =back