Changeset 7a45c4d93a9a6ac0a6ff8932f5ea1ca388fa8a6e

Show
Ignore:
Timestamp:
07/13/09 16:55:09 (5 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1247504109 +0000
git-parent:

[f8b7039b463827f9672411126cfdb1de150e26b9]

git-author:
Mark Harrison <mark@omniti.com> 1247504109 +0000
Message:

Expunge and '--files' support for datasets

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback.in

    rf8b7039 r7a45c4d  
    510510  while (<ZFSLIST>) { 
    511511      my @F = split(' '); 
    512       my ($fs, $snap) = split('@', $F[0]); 
     512      my ($rawfs, $snap) = split('@', $F[0]); 
    513513      #$fs =~ s/$storefs\/?//; 
    514       $fs = get_real_fs_name($fs); 
     514      my $fs = get_real_fs_name($rawfs); 
    515515      my ($whence) = ($snap =~ /(\d+)/); 
    516516      next unless $whence; 
     
    518518      # backup lists 
    519519      $info{$fs}->{full}->{$whence}->{'snapshot'} = $snap; 
     520      $info{$fs}->{full}->{$whence}->{'dataset'} = "$rawfs\@$snap"; 
     521      # Note - this field isn't set for file backups - we probably should do 
     522      # this 
     523      $info{$fs}->{full}->{$whence}->{'pretty_size'} = "$F[1]"; 
    520524      $info{$fs}->{last_full} = $whence if ($whence > 
    521525          $info{$fs}->{last_full}); 
     
    755759    if($DEBUG) { 
    756760      my $tf = config_get($host, 'time_format'); 
    757       print "    => I can remove:\n"; 
     761      print "    => Candidates for removal:\n"; 
    758762      foreach (@backup_points) { 
    759763        print "      => ". strftime($tf, localtime($_)); 
    760764        print " [". (exists($info->{full}->{$_}) ? "full":"incremental") ."]"; 
    761         print " XXX" if(!exists($must_save{$_})); 
     765        print " => marked for removal" if(!exists($must_save{$_})); 
    762766        print "\n"; 
    763767      } 
     
    766770      my $efs = dir_encode($disk); 
    767771      my $filename; 
    768       if(exists($info->{full}->{$_})) { 
    769         $filename = "$store/$_.$efs.full"; 
    770       } 
    771       elsif(exists($info->{incremental}->{$_})) { 
    772         $filename = "$store/$_.$efs.incremental.$info->{incremental}->{$_}->{depends}"; 
    773       } 
    774       else { 
     772      my $dataset; 
     773      if(exists($info->{full}->{$_}->{file})) { 
     774        $filename = $info->{full}->{$_}->{file}; 
     775      } elsif(exists($info->{incremental}->{$_}->{file})) { 
     776        $filename = $info->{full}->{$_}->{file}; 
     777      } elsif(exists($info->{full}->{$_}->{dataset})) { 
     778        $dataset = $info->{full}->{$_}->{dataset}; 
     779      } elsif(exists($info->{incremental}->{$_}->{dataset})) { 
     780        $dataset = $info->{incremental}->{$_}->{dataset}; 
     781      } else { 
    775782        print "ERROR: We tried to expunge $host $disk [$_], but couldn't find it.\n"; 
    776783      } 
    777       print "    => expunging $filename\n" if($DEBUG); 
     784      print "    => expunging ${filename}${dataset}\n" if($DEBUG); 
    778785      unless($NEUTERED) { 
    779         unlink($filename) || print "ERROR: unlink $filename: $?\n"; 
     786        if ($filename) { 
     787          unlink($filename) || print "ERROR: unlink $filename: $?\n"; 
     788        } elsif ($dataset) { 
     789          `__ZFS__ destroy $dataset`; 
     790          if ($?) { 
     791            print "ERROR: zfs destroy $dataset: $?\n"; 
     792          } 
     793        } 
    780794      } 
    781795    } 
     
    969983  print "\t" . strftime($tf, localtime($point)) . " [$point] "; 
    970984  if(exists($info->{full}->{$point})) { 
    971     my @st = stat($info->{full}->{$point}->{file}); 
    972     print "FULL " . pretty_size($st[7]); 
    973     print "\n\tfile: $info->{full}->{$point}->{file}" if($SHOW_FILENAMES); 
     985    if ($info->{full}->{$point}->{file}) { 
     986      my @st = stat($info->{full}->{$point}->{file}); 
     987      print "FULL " . pretty_size($st[7]); 
     988      print "\n\tfile: $info->{full}->{$point}->{file}" if($SHOW_FILENAMES); 
     989    } elsif ($info->{full}->{$point}->{dataset}) { 
     990      print "FULL $info->{full}->{$point}->{pretty_size}"; 
     991      print "\n\tdataset: $info->{full}->{$point}->{dataset}" 
     992        if($SHOW_FILENAMES); 
     993    } 
    974994  } else { 
    975995    my @st = stat($info->{incremental}->{$point}->{file});