Changeset 7bf0fb24f607559b1f4fdbe921349bbe8c9ebb50

Show
Ignore:
Timestamp:
04/18/07 15:14:56 (8 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1176909296 +0000
git-parent:

[005a6e999d24b982ddb035d9e43411aba3462b7d]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1176909296 +0000
Message:

add a -sv flag that displays retention policy violations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback.in

    r005a6e9 r7bf0fb2  
    1616            $PREFIX $CONF $BLOCKSIZE $DEBUG $HOST $BACKUP 
    1717            $RESTORE $RESTORE_HOST $RESTORE_ZFS $TIMESTAMP 
    18             $LIST $SUMMARY $SUMMARY_EXT $FORCE_FULL 
    19             $EXPUNGE $NEUTERED $ZFS 
     18            $LIST $SUMMARY $SUMMARY_EXT $SUMMARY_VIOLATORS 
     19            $FORCE_FULL $EXPUNGE $NEUTERED $ZFS 
    2020            $VERSION $HELP/; 
    2121$version_string = '0.1'; 
     
    3737  zetaback -v 
    3838 
    39   zetaback [-l | -s | -sx] [-c conf] [-d] [-h host] [-z zfs] 
     39  zetaback [-l | -s | -sx | -sv] [-c conf] [-d] [-h host] [-z zfs] 
    4040 
    4141  zetaback -b [-f] [-x] [-c conf] [-d] [-n] [-h host] [-z zfs] 
     
    5656  "s"       => \$SUMMARY, 
    5757  "sx"      => \$SUMMARY_EXT, 
     58  "sv"      => \$SUMMARY_VIOLATORS, 
    5859  "r"       => \$RESTORE, 
    5960  "t=i"     => \$TIMESTAMP, 
     
    7475$actions++ if($SUMMARY); 
    7576$actions++ if($SUMMARY_EXT); 
     77$actions++ if($SUMMARY_VIOLATORS); 
    7678$actions++ if($VERSION); 
    7779if($actions != 1) { 
     
    176178they exist.  For incremental backups, the detail will include any 
    177179incremental backups that are more recent than the last full backup.  
     180 
     181=item -sv 
     182 
     183Display all ZFS disks in the current store that violate the configured 
     184retention policy. 
    178185 
    179186=item -b 
     
    739746} 
    740747 
     748sub pretty_print_backup($$$) { 
     749  my ($info, $host, $point) = @_; 
     750  my $tf = config_get($host, 'time_format'); 
     751  print "\t" . strftime($tf, localtime($point)) . " [$point] "; 
     752  if(exists($info->{full}->{$point})) { 
     753    my @st = stat($info->{full}->{$point}->{file}); 
     754    print "FULL " . pretty_size($st[7]); 
     755  } else { 
     756    my @st = stat($info->{incremental}->{$point}->{file}); 
     757    print "INCR from [$info->{incremental}->{$point}->{depends}] " . pretty_size($st[7]); 
     758  } 
     759  print "\n"; 
     760} 
     761 
    741762sub show_backups($$$) { 
    742763  my ($host, $store, $diskpat) = @_; 
     
    750771         !($disk eq $diskpat ||        # be a specific match or a 
    751772           ($diskpat =~ /^\/(.+)\/$/ && $disk =~ /$1/))); # regex 
     773 
     774    my @backup_points = (keys %{$info->{full}}, keys %{$info->{incremental}}); 
     775    @backup_points = sort { $a <=> $b } @backup_points; 
     776    @backup_points = (pop @backup_points) unless ($SUMMARY_EXT || $SUMMARY_VIOLATORS); 
     777 
     778    # Quick short-circuit in the case of retention violation checks 
     779    if($SUMMARY_VIOLATORS) { 
     780      if(time() > $info->{last_full} + config_get($host, 'full_interval') || 
     781         time() > $info->{last_backup} + config_get($host, 'backup_interval')) { 
     782        print "$host:$disk\n"; 
     783        pretty_print_backup($info, $host, $backup_points[0]); 
     784      } 
     785      next; 
     786    } 
     787 
    752788    # We want to see this one 
    753789    print "$host:$disk\n"; 
     
    759795      } 
    760796    } 
    761     my @backup_points = (keys %{$info->{full}}, keys %{$info->{incremental}}); 
    762     @backup_points = sort { $a <=> $b } @backup_points; 
    763     unless ($SUMMARY_EXT) { 
    764       @backup_points = (pop @backup_points); 
    765     } 
    766797    foreach (@backup_points) { 
    767       print "\t" . strftime($tf, localtime($_)) . " [$_] "; 
    768       if(exists($info->{full}->{$_})) { 
    769         my @st = stat($info->{full}->{$_}->{file}); 
    770         print "FULL " . pretty_size($st[7]); 
    771       } else { 
    772         my @st = stat($info->{incremental}->{$_}->{file}); 
    773         print "INCR from [$info->{incremental}->{$_}->{depends}] " . pretty_size($st[7]); 
    774       } 
    775       print "\n"; 
     798      pretty_print_backup($info, $host, $_); 
    776799    } 
    777800    print "\n"; 
     
    891914    mkdir $store if(! -d $store); 
    892915   
    893     if($LIST || $SUMMARY || $SUMMARY_EXT) { 
     916    if($LIST || $SUMMARY || $SUMMARY_EXT || $SUMMARY_VIOLATORS) { 
    894917      show_backups($host, $store, $ZFS); 
    895918    }