Changeset e8abc5e611648c347b3f86516efff459af085dcb

Show
Ignore:
Timestamp:
08/18/07 15:25:08 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1187450708 +0000
git-parent:

[53f08ad11972b3da0c57137e8af5c5b35caa41fe]

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

closes #16

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback.conf

    r1cf9ca5 re8abc5e  
    11default { 
    22  store = /var/spool/zfs_backups/%h 
     3  archive = /var/spool/zfs_archives/%h 
    34  agent = zetaback_agent 
    45  backup_interval = 86400 
  • zetaback.in

    r53f08ad re8abc5e  
    1818            $LIST $SUMMARY $SUMMARY_EXT $SUMMARY_VIOLATORS 
    1919            $FORCE_FULL $EXPUNGE $NEUTERED $ZFS $SHOW_FILENAMES 
    20             $VERSION $HELP/; 
     20            $ARCHIVE $VERSION $HELP/; 
    2121$version_string = '0.1'; 
    2222$PREFIX = q^__PREFIX__^; 
     
    3939  zetaback [-l | -s | -sx | -sv] [--files] [-c conf] [-d] [-h host] [-z zfs] 
    4040 
     41  zetaback -a [-c conf] [-d] [-h host] [-z zfs] 
     42 
    4143  zetaback -b [-f] [-x] [-c conf] [-d] [-n] [-h host] [-z zfs] 
    4244 
     
    5254  "z=s"     => \$ZFS, 
    5355  "c=s"     => \$CONF, 
     56  "a"       => \$ARCHIVE, 
    5457  "b"       => \$BACKUP, 
    5558  "l"       => \$LIST, 
     
    7174# actions allowed together 'x' and 'b' all others are exclusive: 
    7275my $actions = 0; 
     76$actions++ if($ARCHIVE); 
    7377$actions++ if($BACKUP || $EXPUNGE); 
    7478$actions++ if($RESTORE); 
     
    194198backed up by the next regular zetaback run will often show up as violators. 
    195199 
     200=item -a 
     201 
     202Performs an archive.  This option will look at all eligible backups points 
     203(as restricted by -z and -h) and move those to the configured archive 
     204directory.  The recommended use is to first issues -sx --files and 
     205carefully review available backup points and prune those that are 
     206unneeded.  Then invoked with -a to move only the remaining "desired" 
     207backup points into the archives. 
     208 
    196209=item -b 
    197210 
     
    256269'%h' can be used, which expands to the hostname.  There is no default for 
    257270this setting. 
     271 
     272=item archive 
     273 
     274This is the base directory under which archives are stored.  The format 
     275is the same as the store setting.  This is destination to which files 
     276are relocated when issuing an archive action (-a). 
    258277 
    259278=item agent 
     
    776795  my $backup_info = scan_for_backups($store); 
    777796  my $tf = config_get($host, 'time_format'); 
     797  my @files; 
    778798  foreach my $disk (sort keys %{$backup_info}) { 
    779799    my $info = $backup_info->{$disk}; 
     
    786806    my @backup_points = (keys %{$info->{full}}, keys %{$info->{incremental}}); 
    787807    @backup_points = sort { $a <=> $b } @backup_points; 
    788     @backup_points = (pop @backup_points) unless ($SUMMARY_EXT || $SUMMARY_VIOLATORS); 
     808    @backup_points = (pop @backup_points) unless ($ARCHIVE || $SUMMARY_EXT || $SUMMARY_VIOLATORS); 
    789809 
    790810    # Quick short-circuit in the case of retention violation checks 
     
    800820    # We want to see this one 
    801821    print "$host:$disk\n"; 
    802     next unless($SUMMARY || $SUMMARY_EXT); 
     822    next unless($SUMMARY || $SUMMARY_EXT || $ARCHIVE); 
    803823    if($SUMMARY_EXT) { 
    804824      print "\tLast Full: ". ($info->{last_full} ? strftime($tf, localtime($info->{last_full})) : "Never") . "\n"; 
     
    809829    foreach (@backup_points) { 
    810830      pretty_print_backup($info, $host, $_); 
     831      push @files, exists($info->{full}->{$_}) ? $info->{full}->{$_}->{file} : $info->{incremental}->{$_}->{file}; 
    811832    } 
    812833    print "\n"; 
     834  } 
     835  if($ARCHIVE && scalar(@files)) { 
     836    my $archive = config_get($host, 'archive'); 
     837    $archive =~ s/%h/$host/g; 
     838    if(! -d $archive) { 
     839      mkdir $archive || die "Cannot mkdir($archive)\n"; 
     840    } 
     841    print "\nAre you sure you would like to archive ".scalar(@files)." file(s)? "; 
     842    while(($_ = <>) !~ /(?:y|n|yes|no)$/i) { 
     843      print "Are you sure you would like to archive ".scalar(@files)." file(s)? "; 
     844    } 
     845    if(/^y/i) { 
     846      foreach my $file (@files) { 
     847        (my $afile = $file) =~ s/^$store/$archive/; 
     848        rename($file, $afile) || print "Error archiving $file: $!\n"; 
     849      } 
     850    } 
    813851  } 
    814852} 
     
    926964    mkdir $store if(! -d $store); 
    927965   
    928     if($LIST || $SUMMARY || $SUMMARY_EXT || $SUMMARY_VIOLATORS) { 
     966    if($LIST || $SUMMARY || $SUMMARY_EXT || $SUMMARY_VIOLATORS || $ARCHIVE) { 
    929967      show_backups($host, $store, $ZFS); 
    930968    }