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/; |
63 |
backups.id as backup_id, |
backups.id as backup_id, |
64 |
hosts.name as host, |
hosts.name as host, |
65 |
shares.name as share, |
shares.name as share, |
66 |
backups.num as num |
backups.num as num, |
67 |
|
inc_size |
68 |
from backups |
from backups |
69 |
join shares on backups.hostid = shares.hostid |
join shares on backups.hostid = shares.hostid |
70 |
and shares.id = backups.shareid |
and shares.id = backups.shareid |
71 |
join hosts on shares.hostid = hosts.id |
join hosts on shares.hostid = hosts.id |
72 |
where inc_size < 0 and not inc_deleted |
where not inc_deleted |
73 |
order by backups.date |
order by backups.date |
74 |
|
|
75 |
} ); |
} ); |
77 |
$sth->execute(); |
$sth->execute(); |
78 |
|
|
79 |
my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ? where id = ? }); |
my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ? where id = ? }); |
80 |
|
my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? }); |
81 |
|
|
82 |
%BackupPC::SearchLib::Conf = %Conf; |
%BackupPC::SearchLib::Conf = %Conf; |
83 |
|
|
84 |
while (my $row = $sth->fetchrow_hashref) { |
while (my $row = $sth->fetchrow_hashref) { |
85 |
my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}); |
my $tar_file = BackupPC::SearchLib::getGzipName($row->{'host'}, $row->{'share'}, $row->{'num'}); |
86 |
print curr_time, sprintf(" %s:%s %-3d ", $row->{'host'}, $row->{'share'}, $row->{'num'}), " -> $tar_file "; |
|
87 |
|
my $size = -1; |
88 |
|
$size = (stat( "$tar_dir/$tar_file" ))[7] if (-e "$tar_dir/$tar_file"); |
89 |
|
|
90 |
|
next if ($row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size); |
91 |
|
|
92 |
|
print curr_time, " ", $row->{'host'}, ":", $row->{'share'}, " #", $row->{'num'}, " -> $tar_file"; |
93 |
|
|
94 |
my $t = time(); |
my $t = time(); |
95 |
|
|
100 |
|
|
101 |
my $size = (stat( "$tar_dir/$tar_file" ))[7]; |
my $size = (stat( "$tar_dir/$tar_file" ))[7]; |
102 |
|
|
103 |
print " dur: ",fmt_time(time() - $t)," $size bytes\n"; |
printf(" %1.2f MB, dur: %s", ($size / 1024 / 1024), fmt_time(time() - $t)); |
104 |
|
|
105 |
$sth_inc_size->execute($size, $row->{'backup_id'}); |
if ($size > 45) { |
106 |
|
$sth_inc_size->execute($size, $row->{'backup_id'}); |
107 |
|
$sth_inc_deleted->execute(0, $row->{'backup_id'}); |
108 |
|
} else { |
109 |
|
$sth_inc_deleted->execute(1, $row->{'backup_id'}); |
110 |
|
unlink "$tar_dir/$tar_file" || die "can't delete $tar_dir/$tar_file: $!\n"; |
111 |
|
print " EMPTY"; |
112 |
|
} |
113 |
|
print "\n"; |
114 |
|
|
115 |
$dbh->commit; |
$dbh->commit; |
116 |
|
|