/[BackupPC]/trunk/bin/BackupPC_incPartsUpdate
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_incPartsUpdate

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

revision 194 by dpavlin, Thu Oct 13 17:11:59 2005 UTC revision 196 by dpavlin, Thu Oct 13 18:32:59 2005 UTC
# Line 64  select Line 64  select
64          hosts.name as host,          hosts.name as host,
65          shares.name as share,          shares.name as share,
66          backups.num as num,          backups.num as num,
67          inc_size          inc_size,
68            parts
69  from backups  from backups
70          join shares on backups.hostid = shares.hostid          join shares on backups.hostid = shares.hostid
71                  and shares.id = backups.shareid                  and shares.id = backups.shareid
# Line 76  order by backups.date Line 77  order by backups.date
77    
78  $sth->execute();  $sth->execute();
79    
80  my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ? where id = ? });  my $sth_inc_size = $dbh->prepare(qq{ update backups set inc_size = ?, parts = ? where id = ? });
81  my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? });  my $sth_inc_deleted = $dbh->prepare(qq{ update backups set inc_deleted = ? where id = ? });
82    
83  %BackupPC::SearchLib::Conf = %Conf;  %BackupPC::SearchLib::Conf = %Conf;
# Line 93  while (my $row = $sth->fetchrow_hashref) Line 94  while (my $row = $sth->fetchrow_hashref)
94    
95          # re-create archive?          # re-create archive?
96          if ($row->{'inc_size'} == -1 || $size == -1 || $row->{'inc_size'} != $size) {          if ($row->{'inc_size'} == -1 || $size == -1 || $row->{'inc_size'} != $size) {
97                  my $cmd = qq{$tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};                  my $cmd = qq{rm -Rf $tar_dir/$tar_file && $tarIncCreate -h "$row->{'host'}" -s "$row->{'share'}" -n $row->{'num'} | gzip -9 > $tar_dir/$tar_file};
98                  print STDERR "## $cmd\n" if ($debug);                  print STDERR "## $cmd\n" if ($debug);
99    
100                  system($cmd) == 0 or die "failed: $?";                  system($cmd) == 0 or die "failed: $?";
# Line 104  while (my $row = $sth->fetchrow_hashref) Line 105  while (my $row = $sth->fetchrow_hashref)
105          if ($size > 45) {          if ($size > 45) {
106    
107                  my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar";                  my $max_size = $Conf{'MaxArchiveSize'} || die "problem with MaxArchieSize parametar";
108                    $max_size *= 1024;      # convert to bytes
109    
110                    my $parts = int( ($size + $max_size - 1) / $max_size );
111    
112                    if (-d "$tar_dir/$tar_file" && $parts != $row->{'parts'}) {
113                            print " join";
114    
115                            my $in = my $out = "$tar_dir/$tar_file";
116                            $out .= '.tmp';
117    
118                            # FIXME I should really order parts manually!
119                            system("cat $in/part* > $out && rm -Rf $in && mv $out $in") == 0 or die "can't join $in: $?";
120                    }
121    
122                  if ($size > $max_size && ! -d "$tar_dir/$tar_file") {                  if ($size > $max_size && ! -d "$tar_dir/$tar_file") {
123                          print " split";                          print " split/$parts";
124                          my $in = my $out = "$tar_dir/$tar_file";                          my $in = my $out = "$tar_dir/$tar_file";
125                          $out .= '.tmp';                          $out .= '.tmp';
126                          rename $in, $out || die "can't rename $in: $!";                          rename $in, $out || die "can't rename $in: $!";
127                          mkdir $in || die "can't mkdir $in: $!";                          mkdir $in || die "can't mkdir $in: $!";
128                          system("split -d -b $max_size $out $in/part") == 0 or die "can't split $out: $!";  
129                            my $suffix_len = length("$parts");
130                            system("split -d -b $max_size -a $suffix_len $out $in/part") == 0 or die "can't split $out: $?";
131                          unlink $out || die "can't unlink $out: $!";                          unlink $out || die "can't unlink $out: $!";
132                  }                  }
133    
134                  $sth_inc_size->execute($size, $row->{'backup_id'});                  $sth_inc_size->execute($size, $parts, $row->{'backup_id'});
135                  $sth_inc_deleted->execute(0, $row->{'backup_id'});                  $sth_inc_deleted->execute(0, $row->{'backup_id'});
136    
137                  printf(" %1.2f MB", ($size / 1024 / 1024));                  printf(" %1.2f MB", ($size / 1024 / 1024));

Legend:
Removed from v.194  
changed lines
  Added in v.196

  ViewVC Help
Powered by ViewVC 1.1.26