From 824b4c17a9b7b79f5b2d6541559a1574e71f8624 Mon Sep 17 00:00:00 2001 From: dpavlin Date: Wed, 1 Mar 2006 13:24:36 +0000 Subject: [PATCH 1/1] r10295@llin: dpavlin | 2006-03-01 14:23:33 +0100 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 | 2 +- bin/BackupPC_burnArchiveCLI | 27 ++++++++++++++++++++++----- doc/Search.pod | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/BUGS b/BUGS index bdacd18..367cef6 100644 --- 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 diff --git a/bin/BackupPC_burnArchiveCLI b/bin/BackupPC_burnArchiveCLI index b17f5e0..18013c2 100755 --- a/bin/BackupPC_burnArchiveCLI +++ b/bin/BackupPC_burnArchiveCLI @@ -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}"; diff --git a/doc/Search.pod b/doc/Search.pod index 719fa8d..2e72e40 100644 --- a/doc/Search.pod +++ b/doc/Search.pod @@ -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 -- 2.20.1