3.3.6

Amanda modules list
List of All Modules
All Amanda Releases

Amanda::Tapelist


NAME

Amanda::Tapelist - manipulate the Amanda tapelist


SYNOPSIS

    use Amanda::Tapelist;
    # to get a read only copy of the tapelist file:
    my $tl = Amanda::Tapelist->new("/path/to/tapefile");
    # to read/update/write the tapelist file
    # read and take lock
    my $tl = Amanda::Tapelist->new("/path/to/tapefile", 1);
    # modify the memory copy
    $tl->add_tapelabel($datestamp, $label);
    $tl->add_tapelabel($datestamp2, $label2, $comment, 1);
    # write it and unlock
    $tl->write();
    # If you already have a read only copy and want to modify it
    # take a read only copy
    my $tl = Amanda::Tapelist->new("/path/to/tapefile");
    # reload and take lock
    $tl->reload(1);
    # modify the memory copy
    tl->add_tapelabel($datestamp, $label);
    $tl->add_tapelabel($datestamp2, $label2, $comment, 1);
    # write it and unlock
    $tl->write();


OBJECT-ORIENTED INTERFACE

new returns a hash with no tles set if the tapelist does not exist. tles is an empty array if the tapelist is empty. Invalid entries are silently ignored.

tapelist object

A tapelist object is a hash with the following keys:

filename
  The filename of the tapelist file.
filename_lock
  The filename of the lock file.
fl
  A Amanda::Util::file_lock is the file is locked.
tles

A sequence of tapelist elements (referred to as TLEs in this document), sorted by datestamp from newest to oldest.

tapelist element

A tapelist elementas a hash with the following keys:

position

the one-based position of the TLE in the tapelist

datestamp

the datestamp on which this was written, or "0" for an unused tape

reuse

true if this tape can be reused when it is no longer active

label

tape label

comment

the comment for this tape, or undef if no comment was given


Method

The following methods are available on a tapelist object $tl:

relod($lock)

reload the tapelist file, lock it if $lock is set

lookup_tapelabel($lbl)

look up and return a reference to the TLE with the given label

lookup_tapepos($pos)

look up and return a reference to the TLE in the given position

lookup_tapedate($date)

look up and return a reference to the TLE with the given datestamp

remove_tapelabel($lbl)

remove the tape with the given label

add_tapelabel($date, $lbl, $comment, $reuse)

add a tape with the given date, label, comment and reuse to the end of the tapelist. reuse can be 1 or undef for a reusable volume, it must be 0 for a no-reusable volume.

write() or write($filename)

write the tapelist out to the same file as when read or to $filename if it is set, remove the lock if a lock was taken

unlock()

remove the lock if a lock was taken

clear_tapelist()

remove all tle from the tles.


INTERACTION WITH C CODE

The C portions of Amanda treat the tapelist as a global variable, while this package treats it as an object (and can thus handle more than one tapelist simultaneously). Every call to reload fills this global variable with a copy of the tapelist, and likewise clear_tapelist clears the global. However, any changes made from Perl are not reflected in the C copy, nor are changes made by C modules reflected in the Perl copy.


ABOUT THIS PAGE

This page was automatically generated Wed Aug 20 11:08:45 2014 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.


3.3.6