--- trunk/bin/BackupPC_tarIncCreate 2005/11/10 15:38:14 236 +++ trunk/bin/BackupPC_tarIncCreate 2005/12/12 12:16:01 251 @@ -161,7 +161,8 @@ inc_size = ?, parts = ?, inc_deleted = false - where id = ? }); + where id = ? +}); my $sth_backup_parts = $dbh->prepare(qq{ insert into backup_parts ( backup_id, @@ -204,7 +205,9 @@ my $tar_file = BackupPC::SearchLib::getGzipName($Host, $ShareName, $Num) || die "can't getGzipName($Host, $ShareName, $Num)"; -my $tar_path = $tar_dir . '/' . $tar_file . '.tmp'; +my $tar_path_final = $tar_dir . '/' . $tar_file; +my $tar_path = $tar_path_final . '.tmp'; + $tar_path =~ s#//#/#g; my $sth = $dbh->prepare(qq{ @@ -233,7 +236,7 @@ if ($fh) { return if ($current_tar_size == 0); - print STDERR "# closing part $part\n" if ($opts{d}); + print STDERR " $part" if ($opts{v}); # # Finish with two null 512 byte headers, @@ -264,12 +267,24 @@ $total_increment_size += int( ( $size + 1023 ) / 1024 ) * 1024; if ($arg->{close}) { - print STDERR "# close last part\n" if ($opts{d}); + + if ($part == 1) { + print STDERR " single"; + rename "${tar_path}/1.tar.gz", "${tar_path_final}/.tar.gz" || die "can't move tar ${tar_path}: $! "; + rename "${tar_path}/1.md5", "${tar_path_final}/.md5" || die "can't move md5 ${tar_path}: $! "; + } else { + print STDERR " [last]"; + rename "${tar_path}", "${tar_path_final}" || die "can't move tar ${tar_path}: $! "; + } + $sth_inc_size->execute( $total_increment_size, $part, $backup_id ); + + print STDERR ", $total_increment_size bytes\n" if ($opts{v}); + return; } @@ -557,7 +572,7 @@ sub seedCache($$$) { my ($host, $share, $dumpNo) = @_; - print STDERR curr_time(), "getting files for $host:$share increment $dumpNo..." if ($opts{v}); + print STDERR curr_time(), "$host:$share #$dumpNo" if ($opts{v}); my $sql = q{ SELECT path,size FROM files @@ -569,7 +584,7 @@ my $sth = $dbh->prepare($sql); $sth->execute($host, $share, $dumpNo); my $count = $sth->rows; - print STDERR " found $count items\n" if ($opts{v}); + print STDERR " $count items, parts:" if ($opts{v}); while (my $row = $sth->fetchrow_arrayref) { #print STDERR "+ ", $row->[0],"\n"; $in_backup_increment->{ $row->[0] } = $row->[1]; @@ -617,7 +632,7 @@ # is this file too large to fit into MaxArchiveFileSize? if ( ($current_tar_size + tar_overhead($tarPath) + $size) > $max_file_size ) { - print STDERR "# tar file $current_tar_size + $tar_header_length + $size > $max_file_size, splitting\n" if ($opts{d}); + print STDERR "# tar file $current_tar_size + $tar_header_length + $size > $max_file_size, splitting\n" if ($opts{d}); new_tar_part(); }