Amanda-2.6.1

Amanda::DB::Catalog


NAME

Amanda::DB::Catalog - access to the Amanda catalog: where is that dump?


SYNOPSIS

  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";
      }
  }


DESCRIPTION

MODEL

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:

label

(string) -- volume label

filenum

(integer) -- file on that volume

dump_timestamp

(string) -- timestamp of the run in which the dump was created

write_timestamp

(string) -- timestamp of the run in which the dump was written to this volume

hostname

(string) -- dump hostname

diskname

(string) -- dump diskname

level

(integer) -- dump level

status

(string) -- ``OK'', ``PARTIAL'' or some other descriptor

partnum

(integer) -- part number of a split dump (1-based)

nparts

(integer) -- number of parts in this dump (estimated)

kb

(integer) -- size (in kb) of this dumpfile

sec

(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.

NOTES

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.

QUERIES

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:

write_timestamp

restrict to dumpfiles written at this timestamp

write_timestamps

(arrayref) restrict to dumpfiles written at any of these timestamps

dump_timestamp

restrict to dumpfiles with exactly this timestamp

dump_timestamps

(arrayref) restrict to dumpfiles with any of these timestamps

dump_timestamp_match

restrict to dumpfiles with timestamps matching this expression

hostname

restrict to dumpfiles with exactly this hostname

hostnames

(arrayref) restrict to dumpfiles with any of these hostnames

hostname_match

restrict to dumpfiles with hostnames matching this expression

diskname

restrict to dumpfiles with exactly this diskname

disknames

(arrayref) restrict to dumpfiles with any of these disknames

diskname_match

restrict to dumpfiles with disknames matching this expression

label

restrict to dumpfiles with exactly this label

labels

(arrayref) restrict to dumpfiles with any of these labels

level

restrict to dumpfiles with exactly this level

levels

(arrayref) restrict to dumpfiles with any of these levels

status

restrict to dumpfiles with this status

Match expressions are described in the amanda(8) manual page.

sort_dumps([ $key1, $key2, .. ], @dumps)

Given a list of dumps, this function sorts that list by the requested keys. The following keys are available:

hostname
diskname
write_timestamp
dump_timestamp
level
filenum
label
partnum
kb
sec

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.


API STATUS

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.


ABOUT THIS PAGE

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.


Amanda-2.6.1