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 || -z $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: $!"; |
|
|
$md5 =~ s#\s.*$##; |
|
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 |
|
|