#! /usr/bin/perl # amandatape -- a utility to print amanda tape labels for DAT and CD. # # 2005-02-15 Josef Wolf (jw@raven.inka.de) # # Portions of this program which I authored may be used for any purpose # so long as this notice is left intact. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # I wrote this program because I was dissatisfied with the original label # printing program that comes with the amanda distribution. I wanted to see # from one glance on the newest tape which tapes in which order I need to # recover a specific DLE. # # This program prints tapelabels for the amanda backup system. The output # can be in plain ASCII or in postscript. The postscript output is formatted # so that it can be folded to fit into a DAT case or into a CD jewel case. # # An example ASCII output (somewhat stripped to make it fit into 80 columns) # is attached below. Here is an explanation of the example output: # # The columns in the output have following meanings: # # date: This name seems to be intuitive, but unfortunately, it is somewhat # misleading. Actually, this is the name of the logfile that provided # the corresponding information. # label: The label of the tape. # fn: File number on the tape. # fm: Filemark # Osize: Original (that is, uncompressed) size of the dump(s). # Dsize: Size of the dump(s). This is usually pretty close to Tsize so it # is of very little interest. # Tsize: The size of dump(s) on the tape. # Dtime: Dumper time. # Ttime: Taper Time. # Dspd: Dumper speed. # Tspd: Taper speed. # DLE: Disk list entry. # lv: Dump-level. # dpl: "Dumps per level". This is a list of dump levels (starting with # level 0). # error: An error message. # # The output is split into four sections: # # The first section (if present) lists errors. In the example below we can see # that there were two taper errors and a warning that a DLE must be flushed to # tape. # # The second section contains only one line with four fields: # - date # - tape label # - total amount of data on that tape. # - number of DLEs on that tape and total number of DLEs. # # The third section lists all the tapes that are needed to recover all # DLEs. In the example below we can see that three level0, four level1 # and one level3 from tape VOL01 are needed to do a full restore of all # DLEs. In addition, three level0, one level1 and one level2 from VOL09 # are still needed. Everything else on VOL09 is obsoleted by the dumps # on VOL01. VOL08 contains two level0 and one leve1 that are not obsoleted # by newer tapes. Finally, VOL07 contain one level0 dump that is not # obsoleted by newer tapes. # Tapes that contain only obsoleted data are not mentioned at all unless you # supply the -t command line option. # # The fourth section is the main section and is itself split into multiple # sections, one for each DLE. In this section we can see which tapes we # need to recover a specific DLE. For example, we can see that in order # to recover raven:/u4 we need file 1 from VOL07, file 6 from VOL08, # file 7 from VOL09 and file 1 from VOL01, in this order. # # The Ordering of the sections can be different depending on the choosen # output format. # # Due to lack of space, there is a special handling when output is formatted # for DAT: The fourth section is printed in such a way that non-important data # (everything on the left from the Osize column) is cut off from the label. # # Here comes the example output: # # date Tsize label fm lv error # 2004-02-20.0 1499M VOL06 8 ? writing file: No space left on device # 2004-02-23.0 1499M VOL01 9 ? writing file: No space left on device # 2004-02-23.0 670M ??? ? 0 raven:/m/u1 not on tape yet # # 2004-02-23.0 VOL01 Total:834M DLEs:8/9 # # date label Osize Tsize Ttime dpl # 2004-02-23.0 VOL01 1616M 834M 0:01:06 3/4/0/1 # 2004-02-22.0 VOL09 2885M 1164M 0:01:12 3/1/1 # 2004-02-21.0 VOL08 3427M 1127M 0:01:12 2/1 # 2004-02-20.1 VOL07 2077M 1376M 0:01:24 1 # # Dspd Tspd Dtime Osize Tsize Ttime dumpdate label:fn lv DLE # 803k 11M 0:09:13 1163M 434M 0:00:37 2004-02-21 VOL08:008 0 raven:/ # 461k 105M 0:00:06 15M 2963k 0:00:00 2004-02-23 VOL01:004 1 raven:/ # # 2515k 40M 0:00:01 4520k 3487k 0:00:00 2004-02-22 VOL09:003 0 raven:/boot # 0k 1647k 0:00:00 10k 1k 0:00:00 2004-02-23 VOL01:003 1 raven:/boot # # 971k 19M 0:11:46 1757M 670M 0:00:34 2004-02-21 VOL08:009 0 raven:/u1 # 190k 25M 0:00:00 290k 22k 0:00:00 2004-02-22 VOL09:002 1 raven:/u1 # # 0k 1237k 0:00:00 10k 1k 0:00:00 2004-02-23 VOL01:002 0 raven:/u2 # # 2913k 13M 0:03:56 884M 672M 0:00:49 2004-02-22 VOL09:008 0 raven:/u3 # 925k 13M 0:00:40 94M 36M 0:00:02 2004-02-23 VOL01:006 1 raven:/u3 # # 3254k 16M 0:07:13 2077M 1376M 0:01:24 2004-02-20 VOL07:001 0 raven:/u4 # 314k 42M 0:01:14 505M 22M 0:00:00 2004-02-21 VOL08:006 1 raven:/u4 # 373k 47M 0:00:50 459M 18M 0:00:00 2004-02-22 VOL09:007 2 raven:/u4 # 222k 54M 0:00:00 830k 113k 0:00:00 2004-02-23 VOL01:001 3 raven:/u4 # # 593k 21M 0:13:29 1536M 469M 0:00:22 2004-02-22 VOL09:009 0 raven:/u5 # 270k 113M 0:00:14 39M 3885k 0:00:00 2004-02-23 VOL01:005 1 raven:/u5 # # 1003k 13M 0:06:04 863M 356M 0:00:26 2004-02-23 VOL01:008 0 raven:/usr # # 1960k 11M 0:03:46 602M 434M 0:00:36 2004-02-23 VOL01:007 0 raven:/var # bugs: # - Parses amanda's log files instead of reading its database. # - Depends on assumption that only one amdump per day is run. # - Output formats hardcoded. # todo: # - remove some kludges in the code. use strict; use warnings; use Data::Dumper; use PostScript::Simple; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION=1; my $version=0.4.1; sub VERSION_MESSAGE { my ($fh) = @_; print $fh "$0 Version $version ", '($Rev: 1412 $)', "\n"; } sub help_message { return "Usage: $0 [options] [DLE ...] -f : Choose output format. Existing formats are: Text, DAT, DDS, CD, DVD. The formats DDS and DVD are synonyms for DAT/CD. 'Text' is the default format. All formats except 'Text' are postscript -p : Select A4 or Letter as paper type. A4 is default. -l