199 |
# |
# |
200 |
|
|
201 |
my $max_file_size = $Conf{'MaxArchiveFileSize'} || die "problem with MaxArchiveFileSize parametar"; |
my $max_file_size = $Conf{'MaxArchiveFileSize'} || die "problem with MaxArchiveFileSize parametar"; |
|
$max_file_size *= 1024; |
|
202 |
|
|
203 |
my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}; |
my $tar_dir = $Conf{InstallDir}.'/'.$Conf{GzipTempDir}; |
204 |
die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir && -w $tar_dir); |
die "problem with $tar_dir, check GzipTempDir in configuration\n" unless (-d $tar_dir && -w $tar_dir); |
222 |
my ($backup_id) = $sth->fetchrow_array; |
my ($backup_id) = $sth->fetchrow_array; |
223 |
$sth->finish; |
$sth->finish; |
224 |
|
|
225 |
|
|
226 |
|
# delete exising backup_parts |
227 |
|
my $sth_delete_backup_parts = $dbh->prepare(qq{ |
228 |
|
delete from backup_parts |
229 |
|
where backup_id = ? |
230 |
|
}); |
231 |
|
$sth_delete_backup_parts->execute($backup_id); |
232 |
|
|
233 |
|
|
234 |
print STDERR "backup_id: $backup_id working dir: $tar_dir, max uncompressed size $max_file_size bytes, tar $tar_file\n" if ($opts{d}); |
print STDERR "backup_id: $backup_id working dir: $tar_dir, max uncompressed size $max_file_size bytes, tar $tar_file\n" if ($opts{d}); |
235 |
|
|
236 |
if (-e $tar_path_final) { |
if (-e $tar_path_final) { |
252 |
if ($fh) { |
if ($fh) { |
253 |
return if ($current_tar_size == 0); |
return if ($current_tar_size == 0); |
254 |
|
|
255 |
print STDERR " $part"; |
print STDERR "\n\t+ $part:"; |
256 |
|
|
257 |
# |
# |
258 |
# Finish with two null 512 byte headers, |
# Finish with two null 512 byte headers, |
271 |
|
|
272 |
my $size = (stat( $file . '.tar.gz' ))[7] || die "can't stat ${file}.tar.gz"; |
my $size = (stat( $file . '.tar.gz' ))[7] || die "can't stat ${file}.tar.gz"; |
273 |
|
|
274 |
|
print "$file, $size bytes, $items_in_part items"; |
275 |
|
|
276 |
$sth_backup_parts->execute( |
$sth_backup_parts->execute( |
277 |
$backup_id, |
$backup_id, |
278 |
$part, |
$part, |
300 |
} else { |
} else { |
301 |
print STDERR " [last]" if ($opts{v}); |
print STDERR " [last]" if ($opts{v}); |
302 |
move("${tar_path}", "${tar_path_final}"); |
move("${tar_path}", "${tar_path_final}"); |
303 |
|
|
304 |
|
# if this archive was single part, remove it |
305 |
|
foreach my $suffix (qw/.tar.gz .md5/) { |
306 |
|
my $path = $tar_path_final . $suffix; |
307 |
|
unlink $path if (-e $path); |
308 |
|
} |
309 |
} |
} |
310 |
|
|
311 |
$sth_inc_size->execute( |
$sth_inc_size->execute( |
314 |
$backup_id |
$backup_id |
315 |
); |
); |
316 |
|
|
317 |
print STDERR ", $total_increment_size bytes\n" if ($opts{v}); |
print "\n\ttotal $total_increment_size bytes"; |
318 |
|
|
319 |
return; |
return; |
320 |
} |
} |
333 |
mkdir($tar_path) || die "can't create directory $tar_path: $!"; |
mkdir($tar_path) || die "can't create directory $tar_path: $!"; |
334 |
|
|
335 |
sub abort_cleanup { |
sub abort_cleanup { |
336 |
print STDERR "ABORTED: cleanup temp dir"; |
print STDERR "ABORTED: cleanup temp dir "; |
337 |
rmtree($tar_path); |
rmtree($tar_path); |
338 |
$dbh->rollback; |
$dbh->rollback; |
339 |
exit 1; |
exit 1; |
376 |
print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opts{v}); |
print STDERR "NOTE: no files found for $Host:$ShareName, increment $Num\n" if ($opts{v}); |
377 |
# remove temporary files if there are no files |
# remove temporary files if there are no files |
378 |
rmtree($tar_path); |
rmtree($tar_path); |
379 |
|
|
380 |
|
my $sth = $dbh->prepare(qq{ |
381 |
|
update backups set inc_size = 0, parts = 0, inc_deleted = true |
382 |
|
where id = ? |
383 |
|
}); |
384 |
|
$sth->execute($backup_id); |
385 |
|
|
386 |
} |
} |
387 |
|
|
388 |
# |
# |