8 |
use BackupPC::View; |
use BackupPC::View; |
9 |
use Data::Dumper; |
use Data::Dumper; |
10 |
use Time::HiRes qw/time/; |
use Time::HiRes qw/time/; |
|
use File::Pid; |
|
11 |
use POSIX qw/strftime/; |
use POSIX qw/strftime/; |
12 |
use BackupPC::SearchLib; |
use BackupPC::SearchLib; |
13 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
18 |
|
|
19 |
die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate); |
die "can't find $tarIncCreate: $!\n" unless (-x $tarIncCreate); |
20 |
|
|
21 |
my $debug = 1; |
my $debug = 0; |
22 |
$|=1; |
$|=1; |
23 |
|
|
24 |
my $start_t = time(); |
my $start_t = time(); |
60 |
my $sth = $dbh->prepare( qq{ |
my $sth = $dbh->prepare( qq{ |
61 |
|
|
62 |
select |
select |
63 |
|
backups.id as backup_id, |
64 |
hosts.name as host, |
hosts.name as host, |
65 |
shares.name as share, |
shares.name as share, |
66 |
num as num |
backups.num as num |
67 |
from backups |
from backups |
68 |
join shares on backups.hostid = shares.hostid |
join shares on backups.hostid = shares.hostid |
69 |
and shares.id = backups.shareid |
and shares.id = backups.shareid |
75 |
|
|
76 |
$sth->execute(); |
$sth->execute(); |
77 |
|
|
78 |
|
my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ? where id = ? }); |
79 |
|
my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? }); |
80 |
|
|
81 |
%BackupPC::SearchLib::Conf = %Conf; |
%BackupPC::SearchLib::Conf = %Conf; |
82 |
|
|
83 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
91 |
|
|
92 |
system($cmd) == 0 or die "failed: $?"; |
system($cmd) == 0 or die "failed: $?"; |
93 |
|
|
94 |
print fmt_time(time() - $t),"\n"; |
my $size = (stat( "$tar_dir/$tar_file" ))[7]; |
95 |
|
|
96 |
|
print " dur: ",fmt_time(time() - $t)," $size bytes"; |
97 |
|
|
98 |
|
if ($size > 45) { |
99 |
|
$sth_inc_size->execute($size, $row->{'backup_id'}); |
100 |
|
$sth_inc_deleted->execute(0, $row->{'backup_id'}); |
101 |
|
} else { |
102 |
|
$sth_inc_deleted->execute(1, $row->{'backup_id'}); |
103 |
|
unlink "$tar_dir/$tar_file" || die "can't delete $tar_dir/$tar_file: $!\n"; |
104 |
|
print " EMPTY"; |
105 |
|
} |
106 |
|
print "\n"; |
107 |
|
|
108 |
|
$dbh->commit; |
109 |
|
|
110 |
} |
} |
111 |
|
|