Folks,

Bellow is a copy of the script I have been hacking away at, it is in no way
shape or form even close to being complete.
Once it is completed I will be submitting it to www.backupcentral.com for
public use by whom ever so chooses.

I openly await you input and critique, I am in no way closed minded etc..
and welcome your
input and view!

Regards,
Ron

P.S
I will also post this script as is on my web site this evening at
www.sampier.com/wki.txt




#!/usr/local/bin/perl

#
# WKIClone - Process to clone WKI critical savesets
#
# Copyright (C) 2001  Ronald J. Yacketta
#
# 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
USA.
#

# NOTE:
# DO NOT touch anything regarding date information bellow
# these variables are very very crucial to the success of 
# a valid WKI clone!
$g_version      =       "alpha 1.0";
%months         =       (       "Jan"   =>      "01",
                                "Feb"   =>      "02",
                                "Mar"   =>      "03",
                                "Apr"   =>      "04",
                                "May"   =>      "05",
                                "Jun"   =>      "06",
                                "Jul"   =>      "07",
                                "Aug"   =>      "08",
                                "Sep"   =>      "09",
                                "Oct"   =>      "10",
                                "Nov"   =>      "11",
                                "Dec"   =>      "12"
                        );

%days           =       (       "1"     =>      "01",
                                "2"     =>      "02",
                                "3"     =>      "03",
                                "4"     =>      "04",
                                "5"     =>      "05",
                                "6"     =>      "06",
                                "7"     =>      "07",
                                "8"     =>      "08",
                                "9"     =>      "09"
                        );

$TIME           =       scalar localtime(time-86400);
$TIME           =~
s/(\w\w\w)\s(\w\w\w)\s*(\d+)\s*(\d\d):(\d\d):(\d\d)\s*(\d\d)(\d\d)//;
# I am almost positive this could be done cleaner, I wanted to use unless() 
# but it never seemed to work, then again it could be my syntax
if ( length($3) < 2 )
{
        $DAY            =       $days{$3};
}
else
{
        $DAY            =       $3;
}

# I am not sure why I am doing these var's like this, maybes its my shell
script
# mentality and lack of know how with perl
$MON            =       $months{$2};
$YER            =       $8;
$DATE           =       "$MON\/$DAY\/$YER";
$TODAY          =       `/bin/date +%m/%d/%y`;
#$NDATE         =       `/bin/date +%m_%d_%y`;
$NDATE          =       $TODAY;
$NDATE          =~      s/\//_/g;
chomp ($NDATE);
chomp ($TODAY);
######
######

$MAIL           =       "/bin/mailx";
$MMINFO         =       "/usr/sbin/mminfo";
$NSRCLONE       =       "/usr/sbin/nsrclone";
$GREP           =       "/usr/bin/grep";
$DIR            =       "/var/tmp/clone_sets";
$BACKINT        =       "$DIR/backint_clone";
$CONFIG         =       "$DIR/wkiclone.cfg";
$AWK            =       "/bin/awk";
$CAT            =       "/bin/cat";
$LP             =       "/usr/ucb/lpr/lpr -Phqit";
$SORT           =       "/bin/sort";
$WC             =       "/bin/wc -l";
$WORKFILE       =       "$DIR/workfile";
$VOLS           =       "$DIR/volfile";
$VOLFILE        =       "$DIR/volumes";
$BACKINT        =       "$DIR/backint_clone";
$ONLINE         =       "$DIR/online_clone";
$ARCHIVE        =       "$DIR/archive_clone";
$EXCHANGE       =       "$DIR/exchange_clone";
$FULL           =       "$DIR/full_clone";
$CLONE_FILE     =       "$DIR/clone_file2";
$REPORT         =       "$DIR/$NDATE"."_clone.rpt";

##
##
############################################################################
####
## No need to edit below this line
##


use Getopt::Long;
use Time::Local;

$|=1;
##
## MAIN
##

# Options

# what an ugly hack this is!
if ( -e $REPORT )
{
unlink $REPORT;
unlink $CLONE_FILE;
}

$usage = <<EOT
Usage: wkiclone.pl [OPTION]...

  -a, --archive                   Clone Oracle online archives
  -b, --backint                   Clone HQP brbackup and brarchive
  -c, --complete                  Performs a complete clone of ALL backup 
                                  types listed in this output
                                  (same as wkiclone.pl -b -o -a -e -f)
  -d, --debug                     enable debugging output, no actual cloning
is performed
  -e, --exchange                  Clone Exchange online backups
  -f, --full                      Clone Group controlled FULL backups
  -h, --help                      display this help and exit
  -n, --nodebug                   disables debug; reduces debug level
  -o, --online                    Clone Oracle online backups
  -v, --version                   output version information and exit

Long options can be abbreviated, where such abbreviation is not ambiguous.

EOT
;

# Read Command Line Arguments

GetOptions(
        "help|h"                        => \$opt_help,
        "version|v"                     => \$opt_version,
        "debug|d"                       => \$g_debug,
        "nodebug|n"                     => \$g_nodebug,
        "backint|b"                     => \$g_backint,
        "online|o"                      => \$g_online,
        "archive|a"                     => \$g_archive,
        "exchange|e"                    => \$g_exchange,
        "full|f"                        => \$g_full,
        "complete|c"                    => \$g_comp,
) or die($usage);

if ($opt_help)
{
        print $usage;
        exit(0);
}

if ($opt_version)
{
        print "wkiclone.pl (WKIClone) $g_version\n"
                . "Process to clone WKI critical savesets\n\n"
                . "Copyright (C) 2001  Ronald J. Yacketta\n"
                . "This is free software; see the source for copying
conditions.  There is NO\n"
                . "warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.\n";
        exit(0);
}

if (!$g_backint && !$g_online && !$g_archive && !$g_exchange & !$g_full )
{
        $g_comp=1;
}

# Thanxs to the folks at [EMAIL PROTECTED] for a boat load help here!
# man that list is just a excellent resource of knowledge!
my %servers = ();
open(CFG,"$CONFIG") || die "could not open $CONFIG: $!";
while ($line = <CFG>)
{
        chomp($line);
        if ( $line =~ /^#/ ) { next; }
        my ($name, $list) =   split /:/, $line;
        $servers{$name}   =  [split ' ', $list ];

}
close(BINT);

$g_debug -= $g_nodebug;
$g_debug = 0 if ($g_debug < 0);

# Lets ensure we have a clean REPORT file.
if ( -e $REPORRT ) { unlink $REPORT; }

# Open clean report file for appending
open(RPT, ">>$REPORT") or die "Can't open $REPORT: $!";

# Lets begin the clone process with some generic log/informative verbage
print "Starting WKI clone process for $DATE on ".localtime(time)."\n";

# drop a copy of the bootstrap into the report file
# for future regeneration of our legato server
#system "$MMINFO -B > $WORKFILE";

system "echo \"Starting WKI clone process for $DATE on `date`\" >> $REPORT
";
#system "echo \"Legato Bootstrap information:\n\" >> $REPORT ; $CAT
$WORKFILE >> $REPORT";

if ( $g_backint || $g_comp )
{

# My attempt to parse each value from each type of clone
# to generate a clone report and saveset id's to clone
        for $server (%servers) {
                 # It works! but man it is just plain uggggggggly!
                 $start = @{$servers{$server}}[0];
                 $stop  = @{$servers{$server}}[1];
                foreach $name (@{ $servers{$server} }) {
                        if ($start eq $name || $stop eq $name ) { next; }
                        @output = `$MMINFO -a -r
\"savetime,volume,ssid,name\" -q \"location=sun_etl,savetime > $start 1 days
ago,savetime < $stop today\" -c $name -V -o tR | sort -n -k 4,4 `;
                        print $server."->".$name.": Cloning " . scalar
@output . " savesets\n";
                        shift(@output);
                        print RPT "Clone report for $name from $start $DATE
to $stop $TODAY \n";
                        foreach $save (@output)         
                        {
                                # what a time save unpack is! man it is 100x
better than
                                # trying to regex the data out!
                                ( $date,$volume,$ssid,$file) = unpack ("A9
A15 A11 A*", $save);
                                $date =~ s/ //g;
                                $volume =~ s/ //g;
                                $ssid =~ s/ //g;
                                $file =~ s/ //g;
                                print RPT "$date $ssid $file\n";
                        }
                }
        }
 
}



   


==
         ______           
        /_____/\          Ronald J. Yacketta
       /____ \\ \         Solaris System Engineer   
      /_____\ \\ /        One Pyrex Place
     /_____/ \/ / /       Elmira, NY 14902
    /_____/ /   \//\         
    \_____\//\   / /         
     \_____/ / /\ /       Phone: 607-377-8328
      \_____/ \\ \        Fax:   607-377-8329
       \_____\ \\         Cell:  607-368-0208
        \_____\/          email: [EMAIL PROTECTED]

==
I sense much NT in you.
NT leads to Bluescreen.
Bluescreen leads to downtime.
Downtime leads to suffering.
NT is the path to the darkside.
Powerful Unix is.

Reply via email to