114 |
|
|
115 |
if (my $row = $sth_md5->fetchrow_hashref) { |
if (my $row = $sth_md5->fetchrow_hashref) { |
116 |
return if ( |
return if ( |
117 |
$row->{tar_size} == $tar_size && |
$row->{tar_size} >= $tar_size && |
118 |
$row->{size} == $size && |
$row->{size} == $size && |
119 |
$row->{md5} eq $md5 && |
$row->{md5} eq $md5 && |
120 |
$row->{items} == $items |
$row->{items} == $items |
141 |
if ($debug) { |
if ($debug) { |
142 |
print STDERR " {{ CHECK: ${host}:${share}#${num} and $filename"; |
print STDERR " {{ CHECK: ${host}:${share}#${num} and $filename"; |
143 |
} else { |
} else { |
144 |
print " check"; |
print " check $filename"; |
145 |
} |
} |
146 |
|
|
147 |
my @tar_parts; |
my @tar_parts; |
162 |
|
|
163 |
my $backup_part; |
my $backup_part; |
164 |
|
|
165 |
print " reading"; |
print " reading" if ($opt{d}); |
166 |
|
|
167 |
foreach my $tarfilename (@tar_parts) { |
foreach my $tarfilename (@tar_parts) { |
168 |
|
|
169 |
print STDERR " $tarfilename" if ($debug); |
print STDERR " $tarfilename" if ($debug); |
170 |
|
|
171 |
my $path = "$tar_dir/$tarfilename"; |
my $size = (stat( "$tar_dir/$tarfilename" ))[7] || die "can't stat $tar_dir/$tarfilename"; |
|
my $md5_path = $path; |
|
|
$md5_path =~ s/\.tar\.gz$/.md5/ || die "can't create md5 filename from $md5_path"; |
|
|
if (! -e $md5_path) { |
|
|
print ", creating md5"; |
|
|
system( $bin->{md5sum} . " $path > $md5_path") == 0 or die "can't create md5 $path: $!"; |
|
|
} |
|
|
|
|
|
my $md5 = read_file( $md5_path ) || die "can't read md5sum file $md5_path: $!"; |
|
172 |
|
|
173 |
my $part_nr = 1; |
if ($size > $Conf{MaxArchiveSize}) { |
174 |
$part_nr = $1 if ($tarfilename =~ m#/(\d+)\.tar\.gz#); |
print STDERR " part bigger than media $size > $Conf{MaxArchiveSize} }}" if ($debug); |
175 |
|
$same = 0; |
176 |
|
last; |
177 |
|
} |
178 |
|
|
179 |
my $size = (stat( "$tar_dir/$tarfilename" ))[7] || die "can't stat $tar_dir/$tarfilename"; |
my $path = "$tar_dir/$tarfilename"; |
180 |
|
|
181 |
open(my $fh, "gzip -cd $tar_dir/$tarfilename |") or die "can't open $tar_dir/$tarfilename: $!"; |
open(my $fh, "gzip -cd $tar_dir/$tarfilename |") or die "can't open $tar_dir/$tarfilename: $!"; |
182 |
binmode($fh); |
binmode($fh); |
189 |
push @tar_files, $entry->name; |
push @tar_files, $entry->name; |
190 |
$items++; |
$items++; |
191 |
$tar_size += $entry->size; |
$tar_size += $entry->size; |
192 |
|
|
193 |
|
if ($tar_size > $Conf{MaxArchiveFileSize}) { |
194 |
|
print STDERR " part too big $tar_size > $Conf{MaxArchiveFileSize} }}" if ($debug); |
195 |
|
$same = 0; |
196 |
|
last; |
197 |
|
} |
198 |
|
|
199 |
} |
} |
200 |
|
|
201 |
if ($tar_size > $Conf{MaxArchiveFileSize}) { |
# |
202 |
print STDERR " part too big $tar_size > $Conf{MaxArchiveFileSize} }}" if ($debug); |
# check if md5 exists, and if not, create one |
203 |
$same = 0; |
# |
204 |
last; |
|
205 |
} elsif ($size > $Conf{MaxArchiveSize}) { |
my $md5_path = $path; |
206 |
print STDERR " part bigger than media $size > $Conf{MaxArchiveSize} }}" if ($debug); |
$md5_path =~ s/\.tar\.gz$/.md5/ || die "can't create md5 filename from $md5_path"; |
207 |
$same = 0; |
if (! -e $md5_path || -z $md5_path) { |
208 |
last; |
print ", creating md5"; |
209 |
|
system( $bin->{md5sum} . " $path > $md5_path") == 0 or die "can't create md5 $path: $!"; |
210 |
} |
} |
211 |
|
|
212 |
|
my $md5 = read_file( $md5_path ) || die "can't read md5sum file $md5_path: $!"; |
213 |
|
$md5 =~ s#\s.*$##; |
214 |
|
|
215 |
|
# extract part number from filename |
216 |
|
my $part_nr = 1; |
217 |
|
$part_nr = $1 if ($tarfilename =~ m#/(\d+)\.tar\.gz#); |
218 |
|
|
219 |
|
# |
220 |
|
# finally, check if backup_parts table in database is valid |
221 |
|
# |
222 |
|
|
223 |
check_part($host, $share, $num, $part_nr, $tar_size, $size, $md5, $items); |
check_part($host, $share, $num, $part_nr, $tar_size, $size, $md5, $items); |
224 |
} |
} |
225 |
|
|
304 |
|
|
305 |
print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d}); |
print "# size: $size backup.size: ", $row->{inc_size},"\n" if ($opt{d}); |
306 |
|
|
307 |
if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} == $size) { |
if ( $row->{'inc_size'} != -1 && $size != -1 && $row->{'inc_size'} >= $size) { |
308 |
if ($check) { |
if ($check) { |
309 |
tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) && next; |
tar_check($row->{'host'}, $row->{'share'}, $row->{'num'}, $tar_file) && next; |
310 |
} else { |
} else { |