/[BackupPC]/trunk/bin/BackupPC_tarIncCreate
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_tarIncCreate

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 254 by dpavlin, Mon Dec 12 16:07:27 2005 UTC revision 297 by dpavlin, Thu Jan 26 17:13:55 2006 UTC
# Line 199  my(%HardLinkExtraFiles, @HardLinks); Line 199  my(%HardLinkExtraFiles, @HardLinks);
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);
# Line 223  $sth->execute($Host, $ShareName, $Num); Line 222  $sth->execute($Host, $ShareName, $Num);
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) {
# Line 244  sub new_tar_part { Line 252  sub new_tar_part {
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,
# Line 263  sub new_tar_part { Line 271  sub new_tar_part {
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,
# Line 290  sub new_tar_part { Line 300  sub new_tar_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(
# Line 298  sub new_tar_part { Line 314  sub new_tar_part {
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                  }                  }
# Line 317  sub new_tar_part { Line 333  sub new_tar_part {
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;
# Line 360  if (seedCache($Host, $ShareName, $Num)) Line 376  if (seedCache($Host, $ShareName, $Num))
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  #  #

Legend:
Removed from v.254  
changed lines
  Added in v.297

  ViewVC Help
Powered by ViewVC 1.1.26