Veritas-bu

[Veritas-bu] Does copy 1 always mean primary copy? (Here's the script).

2005-06-01 15:48:48
Subject: [Veritas-bu] Does copy 1 always mean primary copy? (Here's the script).
From: alfonso.correas AT arrakis DOT es (alfonso.correas)
Date: Wed, 1 Jun 2005 21:48:48 +0200 (CEST)
------=_20050601214848_89824
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

This is the script I've told previously. Is a very silly script, but does
their work. Duplicate images from disk to tape and expire it from disk
(Think on the duplication phase of Vaulting but without needing to have
the vault license -- anyone uses it on 4.5???).

 I don't plan to use it more because the 4.5 platforms I administer are
being upgraded to 5.x and disk staging will be used.

The script is provided AS-IS. It works for me on a HP-UX 11.x platform and
(much probably without very slight changes on other *IX'es). Open it in
Notepad. Is quite commented, just needed very little scripting skills to
modificate it to your particular needs. If anything of support of it is
needed (if anyone needs it...) drop me a line and will try to be much
clearer.

-- 
Best regards,
  Alfonso Correas
------=_20050601214848_89824
Content-Type: text/plain;
 name="duplication_script.txt"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment;
 filename="duplication_script.txt"

#! /usr/bin/ksh

# First of all, we create the list of images to duplicate

ls -la /Disk_stu/ | awk '{print $9}' | grep _ > /tmp/ImagenesDuplicar

# Because imagenames contains underscores for some of the info we need, we set 
IFS (Internal Field # Separator) and trim around it...
# We can find the hostname and the timestamp, needed for some ops in the short 
future

export IFS="_"

cat /tmp/ImagenesDuplicar | cut -d _ -f 1,2 | uniq > /tmp/ImagenesDisco
cat /tmp/ImagenesDisco | awk -F_ '{print $1,$1"_"$2}' | sort -k1 > 
/tmp/ImagenesDisco.sort

# IFS another time as a blank for default.
export IFS=" "

# Here we go...
while read -r NomMaq BckId
do
# First here we see if machine matches to some that contains very sensitive 
information and
# we duplicate it to a restricted and high security pool named LOPD_Alto
# (Change it to suit your needs).

if [ $NomMaq = "MACHINE1" ] ;
  then
  echo $NomMaq" va a LOPD_Alto. \n"
  bpduplicate -X -primary -number_copies 1 -dstunit SU-tibet-0 -dp LOPD_Alto 
-fail_on_error 0 -rl 1 -set_primary 1 -backupid $BckId

# We check if the duplication went fine, if not... uh-oh... image isn't expired 
and we send an
# Alarm to IT/O console for the ops.
  if [ $? = 0 ] ;
    then
        mailx -s "vbkmaste: Imagen $BckId correcta." < echo $?
        echo "Backup $BckId Ok, expiring image. \n"
        /usr/bin/yes | bpexpdate -d 0 -backupid $BckId -copy 1
    else
        echo "Backup $BckId INCORRECT, Unexpired image. \n"
        opcmsg a="Bck_Events" o="volcado.cinta.ksh" msg_text="Duplication of 
the image $BckId was wrong. We will try another time on the next round. Take 
note and notify it to admins".
  fi
  else
# We continue matching names. Let's try with other machines that pertain to a 
medium security tape pool.
        if [ $NomMaq="MACHINE2" ] || [ $NomMaq="MACHINE3" ] || [ 
$NomMaq="MACHINE4" ];
        then
                echo $NomMaq" va a LOPD Medio. \n"
                bpduplicate -X -primary -number_copies 1 -dstunit SU-tibet-0 
-dp LOPD_Medio -fail_on_error 0 -rl 1 -set_primary 1 -backupid $BckId
                if [ $? = 0 ] ;
                        then
                        echo "Backup $BckId Ok, expiring image. \n"
                        /usr/bin/yes | bpexpdate -d 0 -backupid $BckId -copy 1
                else
                        echo "Backup $BckId INCORRECT, Unexpired image. \n"
                        opcmsg a="Bck_Events" o="volcado.cinta.ksh" 
msg_text="Duplication of the image $BckId was wrong. We will try another time 
on the next round. Take note and notify it to admins".

                fi
        else
# Another round of machine matching. Low security pool
        if [ $NomMaq="MACHINE5" ] || [ $NomMaq="MACHINE6" ] ;
        then
                echo $NomMaq" va a LOPD_Basico. \n"
                bpduplicate -X -primary -number_copies 1 -dstunit SU-tibet-0 
-dp LOPD_Basico -fail_on_error 0 -rl 1 -set_primary 1 -backupid $BckId
                if [ $? = 0 ] ;
                        then
                        echo "Backup $BckId Ok, expiring image. \n"
                        /usr/bin/yes | bpexpdate -d 0 -backupid $BckId -copy 1
                else
                        echo "Backup $BckId INCORRECT, Unexpired image. \n"
                        opcmsg a="Bck_Events" o="volcado.cinta.ksh" 
msg_text="Duplication of the image $BckId was wrong. We will try another time 
on the next round. Take note and notify it to admins".

                fi
        else
# Last resort. If wasn't matched previously could be a new machine, we 
duplicate it to a generic pool
# We'll look the correct tape pool.

        echo $NomMaq" va a Generic. \n"
        bpduplicate -X -primary -number_copies 1 -dstunit SU-tibet-0 -dp 
Generic -fail_on_error 0 -rl 1 -set_primary 1 -backupid $BckId
                if [$? = 0] ;
                        then
                        echo "Backup $BckId Ok, expiring image. \n"
# If we duplicate it successfully we notify it to the IT/O console noting we 
have a machine who cannot
# figure where belongs.
                        /usr/bin/yes | bpexpdate -d 0 -backupid $BckId -copy 1
                        opcmsg a="Bck_Events" o="volcado.cinta.ksh" 
msg_text="Duplication of an unkown machine and cannot figure where belongs. 
Take note and notify it to admins."
                else
                        echo "Backup $BckId INCORRECT, Unexpired image. \n"
                        opcmsg a="Bck_Events" o="volcado.cinta.ksh" 
msg_text="Duplication of the image $BckId was wrong. We will try another time 
on the next round. Take note and notify it to admins".

                fi        fi
        fi
 fi
done < /tmp/ImagenesDisco.sort
------=_20050601214848_89824--


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