bin/amdumpext
changeset 10 8231f7b00052
parent 9 d176b9443312
child 11 9ad262d8c301
equal deleted inserted replaced
9:d176b9443312 10:8231f7b00052
    35 use constant NO        => 'NO';
    35 use constant NO        => 'NO';
    36 use constant DUMPDATES => '/var/lib/dumpdates';
    36 use constant DUMPDATES => '/var/lib/dumpdates';
    37 use constant FD3       => 3;
    37 use constant FD3       => 3;
    38 use constant FD4       => 4;
    38 use constant FD4       => 4;
    39 
    39 
    40 $SIG{__DIE__} = sub { die "$ME: ", @_ };
    40 $SIG{__DIE__} = sub { die $^S ? '' : "$ME: ", @_ };
    41 
    41 
    42 my %SUPPORT = (
    42 my %SUPPORT = (
    43     CONFIG          => YES,    # --config … (default)
    43     CONFIG          => YES,    # --config … (default)
    44     DISK            => NO,     # --disk …
    44     DISK            => NO,     # --disk …
    45     HOST            => NO,     # --host …
    45     HOST            => NO,     # --host …
   121     # may: $opt_level
   121     # may: $opt_level
   122 
   122 
   123     OK "$ME version $VERSION";
   123     OK "$ME version $VERSION";
   124     OK "euid=$> (" . getpwuid($>) . ')';
   124     OK "euid=$> (" . getpwuid($>) . ')';
   125     OK "egid=" . do {
   125     OK "egid=" . do {
   126         my $gid = (split ' ', $))[0];
   126         my ($gid, undef) = split ' ', $);
   127         my $group = getgrgid $gid;
   127         my $group = getgrgid $gid;
   128         "$gid ($group)";
   128         "$gid ($group)";
   129     };
   129     };
   130     OK "groups=" . do {
   130     OK "groups=" . do {
   131         my (undef, @gids) = split ' ', $);
   131         my (undef, @gids) = split ' ', $);
   133         "@gids (@groups)";
   133         "@gids (@groups)";
   134     };
   134     };
   135 
   135 
   136     foreach my $tool (qw(dump restore)) {
   136     foreach my $tool (qw(dump restore)) {
   137         if ($_ = (grep { -x ($_ .= "/$tool") } split /:/ => $ENV{PATH})[0]) {
   137         if ($_ = (grep { -x ($_ .= "/$tool") } split /:/ => $ENV{PATH})[0]) {
   138             chomp(my $version = (`$_ 2>&1`)[0]);
   138             my ($version, undef) = `$_ 2>&1`;
       
   139 	    chomp $version;
   139             OK "$tool is $version";
   140             OK "$tool is $version";
   140         }
   141         }
   141         else {
   142         else {
   142             ERROR "$tool not found in $ENV{PATH}";
   143             ERROR "$tool not found in $ENV{PATH}";
   143         }
   144         }
   154     # check the dumpdates file
   155     # check the dumpdates file
   155     if ($opt_record) {
   156     if ($opt_record) {
   156         my $dumpdates = $opt_dumpdates ? expand($opt_dumpdates) : DUMPDATES;
   157         my $dumpdates = $opt_dumpdates ? expand($opt_dumpdates) : DUMPDATES;
   157 
   158 
   158         eval { open(my $x, "+>>", $dumpdates) or die "$!\n" };
   159         eval { open(my $x, "+>>", $dumpdates) or die "$!\n" };
   159         if   (chomp $@) { ERROR "dumpdates file \"$dumpdates\": $@" }
   160         if   (chomp $@) { ERROR "dumpdates file $dumpdates: $@" }
   160         else            { OK "dumpdates file: \"$dumpdates\"" }
   161         else            { OK "dumpdates file is $dumpdates" }
   161     }
   162     }
   162 
   163 
   163     exit 0;
   164     exit 0;
   164 }
   165 }
   165 
   166 
   419 
   420 
   420   amdumpext support
   421   amdumpext support
   421   amdumpext selfcheck [options] [--level <level>]    --device <device> 
   422   amdumpext selfcheck [options] [--level <level>]    --device <device> 
   422   amdumpext estimate [options]  [--level <level>]... --device <device> 
   423   amdumpext estimate [options]  [--level <level>]... --device <device> 
   423 
   424 
       
   425 =head1 DESCRIPTION
       
   426 
       
   427 The B<amdumpext> is an application plugin for amanda. It drives the
       
   428 native ext2/3/4 dump/restore programs found on most Linux systems. See L<dump(8)>
       
   429 and L<restore(8)> for more information on these tools.
       
   430 
   424 =head1 COMMANDS
   431 =head1 COMMANDS
   425 
   432 
       
   433 The B<amdumpext> supports the commands from the API description found on 
       
   434 L<http://wiki.zmanda.com/index.php/Application_API/Operations>.
       
   435 
       
   436 =head1 COMMON OPTIONS
       
   437 
   426 =over
   438 =over
   427 
   439 
   428 =item B<support>
   440 =item B<--device> I<device>
   429 
   441 
   430 Send a list of supported features.
   442 The disk device from the disklist.
       
   443 
       
   444 =item B<--disk> I<disk>
       
   445 
       
   446 The diskname from the disklist. Currently ignored.
       
   447 
       
   448 =item B<--host> I<host>
       
   449 
       
   450 The hostname from the disklist. Currently ignored.
       
   451 
       
   452 =item B<--config> I<config>
       
   453 
       
   454 The name of the configuration.
       
   455 
       
   456 =item B<--level> I<level>
       
   457 
       
   458 The level of the backup. 0 means full backup.
       
   459 
       
   460 =item B<--index> I<xml|line>
       
   461 
       
   462 Create an index of the files backed up. XML is not supported yet.
       
   463 (Default: not set, means no index at all)
       
   464 
       
   465 =item B<--message> I<xml|line>
       
   466 
       
   467 The format used for messages. XML is not supported yet.
       
   468 (Default: line)
   431 
   469 
   432 =back
   470 =back
   433 
   471 
   434 =head1 OPTIONS
   472 =head1 COMMANDS
   435 
   473 
   436 =head2 Common Options
   474 =head2 support
   437 
   475 
   438 The following options have to be supported by the application.
   476 This command returns the list of supported features.
   439 
   477 
   440 =over 4
   478 =head2 selfcheck
   441 
   479 
   442 =item B<--config> I<config>
   480 This command instructs B<amdumpext> to so some selfchecks. In an ideal
   443 
   481 world it will detect any problem that might prevent a successful backup.
   444 The configuration to be used (the backup set).
   482 
   445 
   483 mandatory options: device, level
   446 =item B<--host> I<host>
   484 
   447 
   485 =head2 estimate
   448 The host from the DLE.
   486 
   449 
   487 Create an estimate about the amount of data we may expect for the
   450 =item B<--disk> I<disk>
   488 backup. Multi-Level estimates are supported.
   451 
   489 
   452 The disk to be saved. It's some "label" for the device to be backed up.
   490 mandatory options: device, level, ...
   453 
   491 
   454 =item B<--device> I<device>
   492 =head1 PROPERTIES
   455 
   493 
   456 The device to be backed up (may be a device name, a mountpoint).
   494 The properties may be set on the server side to tune the behaviour
   457 
   495 of the application. Currently property setting on the client side is
   458 =back
   496 not supported.
   459 
       
   460 =head2 Optional options
       
   461 
       
   462 The following options need to be supported if indicated by the "support"
       
   463 command.
       
   464 
       
   465 =over
       
   466 
       
   467 =item B<--message> "line"
       
   468 
       
   469 Send messages line by line.
       
   470 
       
   471 =item B<--index> "line"
       
   472 
       
   473 Send the index line by line.
       
   474 
       
   475 =back
       
   476 
       
   477 =cut
       
   478 
       
   479 =head2 Properties
       
   480 
   497 
   481 =over 4
   498 =over 4
   482 
   499 
   483 =item B<--dumpdates> I<dumpdates>
   500 =item B<--dumpdates> I<dumpdates>
   484 
   501 
   485 The location of the dumpdates file. Placeholder "${c}" is allowed and
   502 The location of the dumpdates file. Placeholder "${c}" is allowed and
   486 replaced by the name of the current config.
   503 replaced by the name of the current config.
   487 
   504 
   488 =back
   505 =back
   489 
   506 
       
   507 =head1 TESTING
       
   508 
       
   509 The B<amdumpext> may be tested on the command line. The following output
       
   510 file descriptors are used:
       
   511 
       
   512 =over
       
   513 
       
   514 =item 1 (STDOUT)
       
   515 
       
   516 The normal command output, the data stream.
       
   517 
       
   518 =item 2 (STDERR)
       
   519 
       
   520 Not used by the API, but probably redirected to some log files.
       
   521 
       
   522 =item 3 (messages)
       
   523 
       
   524 Operational messages, often it's postprocessed output of some of 
       
   525 the invoked tools
       
   526 
       
   527 =item 4 (index)
       
   528 
       
   529 If index generation is ordered (via the B<--index> option), the index is 
       
   530 sent to this file descriptor.
       
   531 
       
   532 =back
       
   533 
       
   534 The following shell command line is suitable to test the B<amdumpext>:
       
   535 
       
   536     $ amdumpext backup --device /dev/sda1 --level 0 1>dump 3>messages 4>index
       
   537 
       
   538 If you're interested in reading the messages as they appear:
       
   539 
       
   540     $ amdumpext backup --device /dev/sda1 --level 0 3>&1 1>dump 4>index
       
   541 
       
   542 
   490 =head1 EXAMPLE
   543 =head1 EXAMPLE
   491 
   544 
   492     define application "dump" {
   545 The C<amanda.conf> should contain something similiar to the following
       
   546 stanza:
       
   547 
       
   548     define application "mydump" {
   493         plugin "amdumpext"
   549         plugin "amdumpext"
   494 	# optional - define some additional parameters
   550 	# optional - define some additional parameters
   495         property "dumpdates" "/tmp/dumpdates.${c}"
   551         property "dumpdates" "/tmp/dumpdates.${c}"
   496    }
   552    }
   497 
   553 
       
   554    define dumptype "dump" {
       
   555 	program "APPLICATION"
       
   556 	application "mydump"
       
   557     }
       
   558 
   498 
   559 
   499 =cut
   560 =cut
   500 
   561 
   501 # vim:sts=4 sw=4 aw ai sm:
   562 # vim:sts=4 sw=4 aw ai sm: