1 #!/usr/local/bin/perl -w
4 use lib "__INSTALLDIR__/lib";
10 use Time::HiRes qw/time/;
12 use POSIX qw/strftime/;
13 use BackupPC::SearchLib;
16 my $path = abs_path($0);
17 $path =~ s#/[^/]+$#/#;
18 my $tarIncCreate = $path .= 'BackupPC_tarIncCreate';
20 die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate);
27 my $t_fmt = '%Y-%m-%d %H:%M:%S';
30 my $bpc = BackupPC::Lib->new || die;
31 my %Conf = $bpc->Conf();
32 my $TopDir = $bpc->TopDir();
35 my $dsn = $Conf{SearchDSN} || die "Need SearchDSN in config.pl\n";
36 my $user = $Conf{SearchUser} || '';
38 my $dbh = DBI->connect($dsn, $user, "", { RaiseError => 1, AutoCommit => 0 });
40 my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir};
42 die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir && -w $tar_dir);
47 my $t = shift || return;
49 my ($ss,$mm,$hh) = gmtime($t);
50 $out .= "${hh}h" if ($hh);
51 $out .= sprintf("%02d:%02d", $mm,$ss);
56 return strftime($t_fmt,localtime());
61 my $sth = $dbh->prepare( qq{
68 join shares on backups.hostid = shares.hostid
69 and shares.id = backups.shareid
70 join hosts on shares.hostid = hosts.id
71 where inc_size < 0 and not inc_deleted
78 %BackupPC::SearchLib::Conf = %Conf;
80 while (my $row = $sth->fetchrow_hashref) {
81 my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'});
82 print curr_time, sprintf(" %s:%s %-3d ", $row->{'host'}, $row->{'share'}, $row->{'num'}), " -> $tar_file ";
86 my $cmd = qq{$tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};
87 print STDERR "## $cmd\n" if ($debug);
89 system($cmd) == 0 or die "failed: $?";
91 print fmt_time(time() - $t),"\n";