Changeset 7937fdb5603ddb77ad61e8cfad23ce65e95d7e47

Show
Ignore:
Timestamp:
02/27/07 04:40:31 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1172551231 +0000
git-parent:

[a910d6cd5c3136189524f70bec2cf7d4cc0f3209]

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

First draft of options docs, refs #2

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • zetaback

    ra910d6c r7937fdb  
    1 #!/usr/bin/perl 
     1z#!/usr/bin/perl 
    22 
    33use strict; 
     
    55use MIME::Base64; 
    66use POSIX qw/strftime/; 
    7 use Data::Dumper
     7use Pod::Usage
    88 
    99use vars qw/%conf $version_string 
     
    1212            $LIST $SUMMARY $SUMMARY_EXT 
    1313            $EXPUNGE $NUETERED $ZFS 
    14             $VERSION/; 
     14            $VERSION $HELP/; 
    1515$version_string = '0.1'; 
    1616$CONF = q^/etc/zetaback.conf^; 
     
    1919$conf{'default'}->{'time_format'} = "%Y-%m-%d %H:%M:%S"; 
    2020$conf{'default'}->{'retention'} = 14 * 86400; 
     21 
     22=pod 
     23 
     24=head1 NAME 
     25 
     26zetaback - perform backup, restore and retention policies for ZFS backups. 
     27 
     28=head1 SYNOPSIS 
     29 
     30  zetaback -v 
     31 
     32  zetaback [-l | -s | -sx] [-c conf] [-d] [-h host] [-z zfs] 
     33 
     34  zetaback -b [-x] [-c conf] [-d] [-n] [-h host] [-z zfs] 
     35 
     36  zetaback -x [-b] [-c conf] [-d] [-n] [-h host] [-z zfs] 
     37 
     38  zetaback -r [-c conf] [-d] [-n] [-h host] [-z zfs] [-t timestamp] 
     39              [-rhost host] [-rzfs fs] 
     40 
     41=cut 
    2142 
    2243GetOptions( 
     
    3152  "t=i"     => \$TIMESTAMP, 
    3253  "rhost=s" => \$RESTORE_HOST, 
    33   "rfs=s"   => \$RESTORE_ZFS, 
     54  "rzfs=s"  => \$RESTORE_ZFS, 
    3455  "d"       => \$DEBUG, 
    3556  "n"       => \$NUETERED, 
     
    3758  "v"       => \$VERSION, 
    3859); 
     60 
     61# actions allowed together 'x' and 'b' all others are exclusive: 
     62my $actions = 0; 
     63$actions++ if($BACKUP || $EXPUNGE); 
     64$actions++ if($RESTORE); 
     65$actions++ if($LIST); 
     66$actions++ if($SUMMARY); 
     67$actions++ if($SUMMARY_EXT); 
     68$actions++ if($VERSION); 
     69if($actions != 1) { 
     70  pod2usage({ -verbose => 0 }); 
     71  exit -1; 
     72} 
     73 
     74=pod 
     75 
     76=head1 DESCRIPTION 
     77 
     78The B<zetaback> program is orchiestrates the backup (either full or 
     79incremental) of remote ZFS filesysetms to a local store.  It handles 
     80frequency requirements for both full and incemental backups as well 
     81as retention policies.  In addition to backups, the B<zetaback> tool 
     82allows for the restore of any backup to a specified host and zfs 
     83filesystem. 
     84 
     85=head1 OPTIONS 
     86 
     87The non-optional action command line arguments define the invocation purpose 
     88of B<zetaback>.  All other options are optional and refine the target 
     89of the action specified. 
     90 
     91=head2 Generic Options 
     92 
     93The following options have the same meaning over several actions: 
     94 
     95=over 
     96 
     97=item -c <conf> 
     98 
     99Use the specified file as the configuration file.  The default file, if 
     100none is specified is /etc/zetaback.conf. 
     101 
     102=item -d 
     103 
     104Enable debugging output. 
     105 
     106=item -n 
     107 
     108Don't actually perform any remote commands or expunging.  This is useful with 
     109the -d options to ascertain what would be done if the command was executed 
     110without the -n option. 
     111 
     112=item -t <timestamp> 
     113 
     114Used during the restore process to Specify a point in time selection of a 
     115backup image.  If omitted, the command becomes interactive.  This timestamp 
     116is a UNIX timestamp abd is shown in output of -s and -sx actions. 
     117 
     118=item -rhost <host> 
     119 
     120Specifiy the remote host that is the target for a restore operation.  If 
     121omitted the command becomes interactive. 
     122 
     123=item -rzfs <zfs> 
     124 
     125Specifiy the remote ZFS filesystem that is the target for a restore 
     126operation.  If omitted the command becomes interactive. 
     127 
     128=item -h <host> 
     129 
     130Filters the operation to the host specified.  If <host> is the of the form 
     131/patterm/, it matches 'pattern' as a perl regular expression against available 
     132hosts.  If this option is omitted, no limit is enforced and all hosts are 
     133used for the action. 
     134 
     135=item -z <zfs> 
     136 
     137Filters the operation to the zfs filesystem specified.  If <zfs> is of the 
     138form /pattern/, it matches 'pattern' as a perl regular expression against 
     139available zfs filesystems.  If this option is omitted, no filter is enforced 
     140and all zfs filesystems are used for the action. 
     141 
     142=back 
     143 
     144=head2 Actions 
     145 
     146=over 
     147 
     148=item -v 
     149 
     150Show the version. 
     151 
     152=item -l 
     153 
     154Show a brief listing of available backups. 
     155 
     156=item -s 
     157 
     158Like -l, -s will show a list of backups but provides also the most recent 
     159backup information including timestamp type (full or incremental) and the 
     160size on disk. 
     161 
     162=item -sx 
     163 
     164Shows a extended summary.  In addition to the output provided by the -s 
     165action, the -sx action will show detail of each availble backup and note 
     166the more recent full backup and incremental bakcup if such an incremental 
     167backup exists more recent than the full backup. 
     168 
     169=item -b 
     170 
     171Performs a backup.  This option will investigate all eligible hosts, query 
     172the available filesystems from the remote agent and determine if any such 
     173filesystems require a new full or incremental backup to be taken.  This 
     174option may be combined with the -x option (to clean up afterwards). 
     175 
     176=item -x 
     177 
     178Perform an expunge.  This option will determine which, if any, of the local 
     179backups may be deleted given the retention policy specified in the 
     180configuration. 
     181 
     182=item -r 
     183 
     184Perform a restore.  This option will operate on the specified backup and 
     185restore it to the a zfs filesystem specified with -rzfs on the host specified 
     186with the -rhost option.  The -h, -z and -t options may be used to filter 
     187the source backup list.  If the filtered list contains more than one 
     188source backup image, the command will act interactively.  If the -rhost 
     189and -rzfs command are not specified, the command will act interactively. 
     190 
     191=back 
     192 
     193=cut 
    39194 
    40195if($VERSION) { 
     
    358513    $command = "/usr/sbin/zfs recv $fs"; 
    359514  } 
    360   open(DUMP, "gzip -dfc $file |"); 
    361   eval { 
    362     open(RECEIVER, "| ssh $host $command"); 
    363     my $buffer; 
    364     while(my $len = sysread(DUMP, $buffer, $BLOCKSIZE)) { 
    365       if(syswrite(RECEIVER, $buffer, $len) != $len) { 
    366         die "$!"; 
    367       } 
    368     } 
    369   }; 
    370   close(DUMP); 
    371   close(RECEIVER); 
     515  print " => piping $file to $command\n" if($DEBUG); 
     516  unless($NUETERED) { 
     517    open(DUMP, "gzip -dfc $file |"); 
     518    eval { 
     519      open(RECEIVER, "| ssh $host $command"); 
     520      my $buffer; 
     521      while(my $len = sysread(DUMP, $buffer, $BLOCKSIZE)) { 
     522        if(syswrite(RECEIVER, $buffer, $len) != $len) { 
     523          die "$!"; 
     524        } 
     525      } 
     526    }; 
     527    close(DUMP); 
     528    close(RECEIVER); 
     529  } 
    372530  return $?; 
    373531} 
     
    500658    mkdir $store if(! -d $store); 
    501659   
     660    if($LIST || $SUMMARY || $SUMMARY_EXT) { 
     661      show_backups($host, $store, $ZFS); 
     662    } 
    502663    if($BACKUP) { 
    503664      plan_and_run($host, $store, $ZFS); 
    504665    } 
    505     if($LIST || $SUMMARY || $SUMMARY_EXT) { 
    506       show_backups($host, $store, $ZFS); 
    507     } 
    508666    if($EXPUNGE) { 
    509667      perform_retention($host, $store); 
    510668    } 
    511669  } 
    512 }  
     670
     671 
     672exit 0; 
     673 
     674=pod 
     675 
     676=head1 FILES 
     677 
     678=over 
     679 
     680=item /etc/zetaback.conf 
     681 
     682The main zetaback configuration file.  The location of the file can be 
     683specified on the command line with the -c flag.  
     684 
     685=back 
     686 
     687=head1 SEE ALSO 
     688 
     689zetaback.conf(5), zetaback_agent(1), zetback_agent.conf(5) 
     690 
     691=cut