10 |
use Data::Dumper; |
use Data::Dumper; |
11 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
12 |
use POSIX qw/strftime/; |
use POSIX qw/strftime/; |
|
use BackupPC::SearchLib; |
|
13 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
14 |
use File::Which; |
use File::Which; |
15 |
use Archive::Tar::Streamed; |
use Archive::Tar::Streamed; |
16 |
use Algorithm::Diff; |
use Algorithm::Diff; |
17 |
use Getopt::Std; |
use Getopt::Std; |
18 |
|
|
19 |
|
my $bpc = BackupPC::Lib->new || die "can't create BackupPC::Lib"; |
20 |
|
my %Conf = $bpc->Conf(); |
21 |
|
|
22 |
|
use BackupPC::SearchLib; |
23 |
|
%BackupPC::SearchLib::Conf = %Conf; |
24 |
|
|
25 |
# cludge: minimum .tar.gz size |
# cludge: minimum .tar.gz size |
26 |
my $MIN_TAR_SIZE = 80; |
my $MIN_TAR_SIZE = 80; |
27 |
|
|
48 |
|
|
49 |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
my $t_fmt = '%Y-%m-%d %H:%M:%S'; |
50 |
|
|
|
my $hosts; |
|
|
my $bpc = BackupPC::Lib->new || die; |
|
|
my %Conf = $bpc->Conf(); |
|
|
my $TopDir = $bpc->TopDir(); |
|
|
my $beenThere = {}; |
|
|
|
|
51 |
my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n"; |
52 |
my $user = $Conf{SearchUser} || ''; |
my $user = $Conf{SearchUser} || ''; |
53 |
|
|
177 |
my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ?, parts = ? where id = ? }); |
my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ?, parts = ? where id = ? }); |
178 |
my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? }); |
my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? }); |
179 |
|
|
|
%BackupPC::SearchLib::Conf = %Conf; |
|
180 |
|
|
181 |
$sth->execute(); |
$sth->execute(); |
182 |
my $num_backups = $sth->rows; |
my $num_backups = $sth->rows; |
210 |
|
|
211 |
if ($size > $MIN_TAR_SIZE) { |
if ($size > $MIN_TAR_SIZE) { |
212 |
|
|
213 |
my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar"; |
my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchiveSize parametar"; |
214 |
$max_size *= 1024; # convert to bytes |
$max_size *= 1024; # convert to bytes |
215 |
|
|
216 |
|
my $max_file_size = $Conf{'MaxArchiveFileSize'} || die "problem with MaxArchiveFileSize parametar"; |
217 |
|
$max_file_size *= 1024; # bytes |
218 |
|
|
219 |
|
if ($max_file_size > $max_size) { |
220 |
|
warn "MaxArchiveFileSize ($max_file_size) is bigger than MaxArchiveSize ($max_size)\n"; |
221 |
|
$max_file_size = $max_size; |
222 |
|
} |
223 |
|
|
224 |
# maximum file size on ISO image is 4Gb |
# maximum file size on ISO image is 4Gb |
225 |
# this will require Linux kernel 2.6.8 or newer |
# this will require Linux kernel 2.6.8 or newer |
226 |
my $max_iso_file_size = 2^32 - 2048; |
if ( $max_size > $max_file_size ) { |
227 |
if ( $max_size > $max_iso_file_size ) { |
$max_size = $max_file_size; |
|
$max_size = $max_iso_file_size; |
|
228 |
} |
} |
229 |
|
|
230 |
my $parts = int( ($size + $max_size - 1) / $max_size ); |
my $parts = int( ($size + $max_size - 1) / $max_size ); |