ADSM-L

Re: HOW TO SCRIPT TSM BACKUP VERIFICATION IN WINDOWS

2005-10-28 18:07:09
Subject: Re: HOW TO SCRIPT TSM BACKUP VERIFICATION IN WINDOWS
From: Richard Cowen <Richard.Cowen AT MCDATA DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Fri, 28 Oct 2005 16:06:55 -0600
Oops.

Here is the perl code in-line.

----------------------------------------
#!/usr/local/bin/perl
#
# USes a query backup to verify a directory is backed up.
#
# Assumptions:
#
#       The normal TSM environmentals will need to be set
(DSM_DIR,DSM_CONFIG).
#       The dsmc.exe will need to be locatable by the PATH variable.
#       All configuration, log files, etc will be found in the working
directory.
#       The dsm.op file has password generate set.
#
# INVOCATION: dircomp.pl dir_path_name
#
#
# -d debugging
# -h help
# -p pathname
# -w host is windows


$version="1.0";

#
# HISTORY:
#
# 10/28/2005    Started.
#

require "getopts.pl";

Getopts('wdhp:');

if ($opt_h) {
        print "Version $version\n";
        print "dircomp -p <full path name to directory> -d -h -w\n";
        print " -d debugging\n -h help\n -w windows\n";
        exit;
        }


($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$year+=1900;  #number of years since 1900

$ryear=$year;                   # for debugging
$rmon=sprintf("%02d",$mon+1);

$tmon=sprintf("%02d",$mon+1);

$tmday=sprintf("%02d",$mday);
$thour=sprintf("%02d",$hour);
$tmin=sprintf("%02d",$min);
$tsec=sprintf("%02d",$sec);
$timestamp="$year/$tmon/$tmday $thour:$tmin:$tsec";

if ($opt_w) {
        $slash="\\";
        $mkdir="mkdir";
        $pathsep="\\";
        $PATHsep=";";
        $attrib="attrib ";
        $cd="chdir /d";
        $dsmexec="dsmc.exe";
        }
else {
        $slash="/";
        $mkdir="mkdir -p";
        $pathsep="/";
        $PATHsep=":";
        $dsmexec="dsmc";
        }

die "No pathname for directory specified - use the p flag\n" if !$opt_p;

$dirpath=$opt_p;
$dsmpath=$dirpath;

if ($opt_w) {
        open(CHDIR,"chdir |");$mydir=<CHDIR>;close(CHDIR);chomp $mydir;
        print "Current dir: $mydir\n" if $opt_d;
        }


print "DSM_CONFIG $ENV{DSM_CONFIG}\n" if $opt_d;
print "DSM_DIR $ENV{DSM_DIR}\n" if $opt_d;


undef %dirfiles;



opendir(LIST,$opt_p);
while ($filename=readdir(LIST)) {
        chomp $filename;
        next if $filename eq ".";
        next if $filename eq "..";
        $dirfiles{$filename}=1;
        print "local file $filename\n" if $opt_d;
        }
closedir(LIST);

undef %dsmfiles;

$command_base="$dsmexec query backup ";

if ($opt_w) {
        $command=$command_base . $dsmpath . $slash . $slash;
        }
else {
        $command=$command_base . $dsmpath . $slash;
        }

print "Will issue query backup command $command\n" if $opt_d;

# IBM Tivoli Storage Manager
# Command Line Backup/Archive Client Interface - Version 5, Release 2,
Level 3.11
# (c) Copyright by IBM Corporation and other(s) 1990, 2004. All Rights
Reserved.

# Node Name: 17668XP
# Session established with server 17668XP_SERVER2: Windows
#   Server Version 5, Release 3, Level 0.0
#   Server date/time: 10/28/2005 16:20:21  Last access: 10/28/2005
16:20:02
#
#             Size      Backup Date        Mgmt Class A/I File
#             ----      -----------        ---------- --- ----
#             0  B  10/28/2005 16:20:02    STANDARD    A
\\17668xp\c$\edrive\reporting\test

$skip=1;


open(CMD,"$command|") || die "Can't issue $command $!\n";

while ($line=<CMD>) {
        chomp $line;
#       print "dsmc output $line\n" if $opt_d;
        if ($skip) {
                if ($line=~/-----------/) {
                        $skip=0;
                        }
                }
        else {

($size,$scale,$date,$time,$mgmt,$active,$fullpath)=split(" ",$line);
                if ($opt_w) {
                        @words=split(/\\/,$fullpath);
                        }
                else {
                        @words=split(/\//,$fullpath);
                        }
                $lastword=$words[$#words];

                print "dsm fullpath $fullpath, file: $lastword\n" if
$opt_d;
                $dsmfiles{$lastword}=1;
                }
        } # while
close(CMD);

foreach $filename (sort keys %dirfiles) {
        if ($dsmfiles{$filename}) {
                print "$filename is backed up\n" if $opt_d;
                }
        else {
                print "$filename not backed up\n";
                }
        } # foreach


exit;
---------------------------------------

SPECIAL NOTICE

All information transmitted hereby is intended only for the use of the
addressee(s) named above and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution
of confidential and privileged information is prohibited. If the reader
of this message is not the intended recipient(s) or the employee or agent
responsible for delivering the message to the intended recipient, you are
hereby notified that you must not read this transmission and that disclosure,
copying, printing, distribution or use of any of the information contained
in or attached to this transmission is STRICTLY PROHIBITED.

Anyone who receives confidential and privileged information in error should
notify us immediately by telephone and mail the original message to us at
the above address and destroy all copies.  To the extent any portion of this
communication contains public information, no such restrictions apply to that
information. (gate02)

<Prev in Thread] Current Thread [Next in Thread>