Amanda::DB::Catalog - access to the Amanda catalog: where is that dump?
use Amanda::DB::Catalog;
# get all dump timestamps on record my @timestamps = Amanda::DB::Catalog::get_timestamps();
# loop over those timestamps, printing dump info for each one for my $timestamp (@timestamps) { my @dumpfiles = Amanda::DB::Catalog::get_dumps( timestamp => $timestamp, ok => 1 ); print "$timstamp:\n"; for my $dumpfile (@dumpfiles) { print " ", $dumpfile->{hostname}, ":", $dumpfile->{diskname}, " level ", $dumpfile->{level}, "\n"; } }
The Amanda catalog is a set of dumpfiles, where each dumpfile corresponds to a single file in a storage volume. On tapes, files are separated by filemarks and numbered sequentially. This model is preserved on non-tape media such as the VFS and S3 devices. A dumpfile, then, is completely specified by a volume label and a file number (filenum).
The catalog is presented as a single table containing one row per dumpfile. Each row has the following values:
(string) -- volume label
(integer) -- file on that volume
(string) -- timestamp of the run in which the dump was created
(string) -- timestamp of the run in which the dump was written to this volume
(string) -- dump hostname
(string) -- dump diskname
(integer) -- dump level
(string) -- ``OK'', ``PARTIAL'' or some other descriptor
(integer) -- part number of a split dump (1-based)
(integer) -- number of parts in this dump (estimated)
(integer) -- size (in kb) of this dumpfile
(integer) -- time (in seconds) spent writing this dumpfile
A dumpfile is represented as a hashref with these keys.
The label and filenum serve as a primary key. The dump_timestamp, hostname, diskname, and level uniquely identify the dump. The write_timestamp gives the time that the dump was written to this volume. The write_timestamp may differ from the dump_timestamp if, for example, amflush wrote the dump to tape after the initial dump. The remaining fields are informational.
A dumpfile may be a part of a larger (split) dump, or may be partial (due to end of tape or some other error), so the contents of the catalog require some interpretation in order to find a particular dump.
All timestamps used in this module are full-length, in the format
YYYYMMDDHHMMSS
. If the underlying data contains only datestamps, they are
zero-extended into timestamps: YYYYMMDD000000
. A dump_timestamp always
corresponds to the initiation of the original dump run, while
write_timestamp gives the time the file was written to the volume. When
dumpfiles are migrated from volume to volume (e.g., by amflush), the
dump_timestamp does not change.
In Amanda, the tuple (hostname, diskname, level, dump_timestamp) serves as a unique identifier for a dump. Since all of this information is preserved during migrations, a catalog query with these four terms will return all dumpfiles relevant to that dump.
This API is read-only at the moment. The following functions are available:
get_write_timestamps()
Get a list of all write timestamps, sorted in chronological order.
get_latest_write_timestamp()
Return the most recent write timestamp.
get_labels_written_at_timestamp($ts)
Return a list of labels for volumes written at the given timestamp.
get_dumps(%parameters)
This function is the workhorse query interface, and returns a sequence of
dumpfiles. Values in %parameters
restrict the set of dumpfiles that are
returned. The hash can have any of the following keys:
restrict to dumpfiles written at this timestamp
(arrayref) restrict to dumpfiles written at any of these timestamps
restrict to dumpfiles with exactly this timestamp
(arrayref) restrict to dumpfiles with any of these timestamps
restrict to dumpfiles with timestamps matching this expression
restrict to dumpfiles with exactly this hostname
(arrayref) restrict to dumpfiles with any of these hostnames
restrict to dumpfiles with hostnames matching this expression
restrict to dumpfiles with exactly this diskname
(arrayref) restrict to dumpfiles with any of these disknames
restrict to dumpfiles with disknames matching this expression
restrict to dumpfiles with exactly this label
(arrayref) restrict to dumpfiles with any of these labels
restrict to dumpfiles with exactly this level
(arrayref) restrict to dumpfiles with any of these levels
restrict to dumpfiles with this status
Match expressions are described in the amanda(8)
manual page.
Given a list of dumps, this function sorts that list by the requested keys. The following keys are available:
Keys are processed from left to right: if two dumps have the same value for
$key1
, then $key2
is examined, and so on. Key names may be prefixed by
``-
'' to reverse the order.
add_dump($dumpfile)
Add the given dumpfile to the database. In terms of logfiles, this will either
create a new logfile (if the dump's write_timestamp
has not been seen
before) or append to an existing logfile. Note that a new logfile will require
a corresponding new entry in the tapelist.
Note that no locking is performed: multiple simultaneous calls to this function can result in a corrupted or incorrect logfile.
New summary functions may be added to reduce code duplication in other parts of Amanda.
Support for loading and modifying the tapelist may eventually be folded into this module.
This page was automatically generated Fri Feb 5 19:41:21 2010 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.