if I can't find gzip size return original one
[BackupPC.git] / bin / BackupPC_burnArchiveCLI
index 399e2a4..4e2086b 100755 (executable)
@@ -2,17 +2,16 @@
 
 use strict;
 
-use lib "__INSTALLDIR__/lib";
+use lib "/usr/local/BackupPC/lib";
 
 use DBI;
 use BackupPC::Lib;
-use BackupPC::SearchLib;
+use BackupPC::Search;
 use Time::HiRes qw/time/;
 use POSIX qw/strftime/;
 use Term::Menus;
 use File::Which;
 use File::Path;
-use Filesys::Df;
 use Cwd qw/abs_path/;
 use Data::Dumper;
 
@@ -24,7 +23,7 @@ $|=1;
 # don't check for user
 my $bpc = BackupPC::Lib->new(undef, undef, 1) || die;
 my %Conf = $bpc->Conf();
-%BackupPC::SearchLib::Conf = %Conf;
+%BackupPC::Search::Conf = %Conf;
 
 my $conf_bin;
 
@@ -53,8 +52,7 @@ my $user = $Conf{SearchUser} || '';
 
 my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 1 });
 
-my $tar_dir = $Conf{InstallDir}.'/';
-$tar_dir .= $Conf{GzipTempDir} || die "GzipTempDir isn't defined in configuration";
+my $tar_dir = $Conf{GzipTempDir} || die "GzipTempDir isn't defined in configuration";
 
 die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir);
 
@@ -64,6 +62,14 @@ die "problem with $iso_dir, check ISOTempDir in configuration\n" unless (-d $iso
 
 #---- subs ----
 
+sub df_bytes_available {
+       my $path = shift;
+       my $out = `df -P $path`;
+       my $bytes = (split(/\s+/, (split(/\n/,$out))[-1]))[3];
+       return $bytes * 1024;
+
+}
+
 sub fmt_time {
        my $t = shift || return;
        my $out = "";
@@ -397,7 +403,7 @@ foreach my $copy_nr ( 1 .. $copies ) {
 
                        # this part
                        my $p = {
-                               filename => BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}),
+                               filename => BackupPC::Search::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}),
                                host => $row->{'host'},
                                share => $row->{'share'},
                                num => $row->{'num'}
@@ -413,8 +419,7 @@ foreach my $copy_nr ( 1 .. $copies ) {
 
                # check available disk space
 
-               my $df = df($iso_dir)->{bavail} || die "can't get free space on $iso_dir";
-               $df *= 1024;    # calulate space in bytes
+               my $df = df_bytes_available($iso_dir);
                if ($df < $v_size) {
                        warn "ABORTED: not enough disk space to create ISO ! [need ", fmt_mb($v_size), " have ", fmt_mb( $df ), " on $iso_dir]\n";
                        next;
@@ -579,7 +584,7 @@ SKIP:
 
 }
 
-#my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});
+#my $tar_file = BackupPC::Search::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});
 #print curr_time, sprintf(" %s:%s %-3d ", $row->{'host'}, $row->{'share'}, $row->{'num'}), " -> $tar_file ";
 
 print "Recoding finished, exiting...\n";