Amanda::Header - Amanda-specific headers prepended to dump files
# create a header my $hdr = Amanda::Header->new(); $hdr->{type} = $Amanda::Header::F_DUMPFILE; $hdr->{name} = "localhost"; $hdr->{disk} = "/home";
# make a string suitable for use in a dumpfile (NUL-padded) my $block = $hdr->to_string(32768, 32768);
# parse a string into a header $hdr = Amanda::Header->from_string($block);
print "Working on: ", $hdr->summary(), "\n";
Note that, due to the vagaries of SWIG wrapping, headers actually have
class Amanda::Header::Header
.
The constructor creates a new, blank header, which will need at least some of its attributes set before being used. These are set just like any hashref-based object:
$hdr->{'dumplevel'} = 13;
To construct a new object from a bytestring (as read from the beginning of a dumpfile), use
Amanda::Header->from_string($data);
To convert a header object into a bytestring, use the to_string(min,
max)
method. This method takes a minimum and maximum size. If the
header is smaller than the minimum size, it is padded with NUL bytes;
if it would be larger than the maximum size, the method returns
undef
.
The summary
method returns a single-line summary of the header, with
no trailing newline.
As a debugging utility, the debug_dump
method dumps the contents of
the object to the debug log.
To compare a header to a list of dumpspecs (see Amanda::Cmdline), use
if ($hdr->matches_dumpspecs([@dumpspecs])) { ... }
which is really a call to Amanda::Cmdline::header_matches_dumpspecs
.
A header object has the following keys:
type datestamp dumplevel compressed encrypted comp_suffix encrypt_suffix name hostname (F_DUMPFILE) or label (F_TAPESTART) disk program application srvcompprog clntcompprog srv_encrypt clnt_encrypt recover_cmd uncompress_cmd decrypt_cmd srv_decrypt_opt clnt_decrypt_opt cont_filename dle_str is_partial partnum totalparts (-1 == UNKNOWN) blocksize orig_size
type
is one of the following constants, which are availble for
import in the tag :constants
:
F_UNKNOWN F_WEIRD F_TAPESTART F_TAPEEND F_DUMPFILE F_CONT_DUMPFILE F_SPLIT_DUMPFILE F_EMPTY F_NOOP
Some of the header fields are interrelated. The following restrictions apply.
comp_suffix
is set if and only if compressed
is true; the suffix "N" is
reserved and cannot be used.
encrypt_suffix
is set if and only if encrypted
is true; the suffix "N" is
reserved and cannot be used.
If totalparts
is not -1, then partnum
must be less than or equal to
totalparts
. Neither parameter can be zero. These parameters are only
recorded in a F_SPLIT_DUMPFILE
header.
The blocksize
is intended for the user's convenience only. It is written to
the header string, but not parsed on return. from_string
will always return
a header with blocksize=0.
Like blocksize
, recover_cmd
, uncompress_cmd
and decrypt_cmd
are
intended for the user's convenience noly. The uncompress_cmd
and
decrypt_cmd
, if specified, must end with |
(the shell pipe character).
Neither can be nonempty unless recover_cmd
is also nonempty. When parsing a
header with only two commands from a string, it is ambiguous whether the first
string is for decryption or uncompression, and this package assumes
uncompression.
This page was automatically generated Tue Nov 19 20:05:35 2013 from the Amanda source tree, and documents the most recent development version of Amanda. For documentation specific to the version of Amanda on your system, use the 'perldoc' command.