X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_burnArchiveCLI;h=768aa27cfd38862a176bf44a9f29e5fffc15f09f;hp=399e2a4967224b007620629304e878ea20a51598;hb=d1bfa4d92bec24954f2e7877f6531644bb84e8f3;hpb=e55a4b2d45a4c1fa30be604f360ac7bb55e5594c diff --git a/bin/BackupPC_burnArchiveCLI b/bin/BackupPC_burnArchiveCLI index 399e2a4..768aa27 100755 --- a/bin/BackupPC_burnArchiveCLI +++ b/bin/BackupPC_burnArchiveCLI @@ -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 = ""; @@ -386,7 +392,7 @@ foreach my $copy_nr ( 1 .. $copies ) { 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; @@ -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";