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;
# 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;
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);
#---- 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 = "";
my $v; # emtpy volume
my $v_size = 0;
- my $max_archive_size = $Conf{MaxArchiveSize} || die "no MaxArchiveSize";
+ 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) {
push @volumes, $v;
# 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'}
# 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;
}
-#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";