#!/usr/bin/sh # # File: _3par_create_virtual_copy.sh # # Auth: Prasanth V Aravindakshan # # Prasanth.vattoly@gmail.com # # pvaravind@copycatltd.com # # # Desc: Script to create Snap shots for all t24 production volumes & allocate it to # business copy server # # The script takes one arguemnt: an account name. # # Modifications: # Date Author Desc # # # 17/07/12 Prasanth TEsting # # # # # ##------------------------------------------------------------------------ # Create the main log directory for the script #------------------------------------------------------------------------ echo ' ' echo ' ' echo ' WARNING:- Ensure that you have unmounted the t24 filesystems & unpresented the virtual volumes ' echo ' From Business copy server before you run this script. If any of the t24 filesystem is mounted ' echo ' this script will fail ' echo ' ' echo ' ' echo ' Starting the script ........ ' #------------------------------------------------------------------------ # Create base file with the list of filesystems to be mount #------------------------------------------------------------------------ echo ' Creating base files for run ........ ' echo ' /dev/vgbctest/lv2 /bctest2 /dev/vgbctest/lv1 /bctest1 ' > /tmp/3parvclogs/filesystems # echo '/dev/vgshare/lvshare /t24/share #/dev/vgstubs/lvstubs /t24/stubs #/dev/vgoracle/lvoracle /u01 #/dev/vgoradata/lvoradata /u02 #/dev/vgoraarch/lvoraarch /u03 ' > /tmp/3parvclogs/filesystems #------------------------------------------------------------------------ # Create base file with vglist #------------------------------------------------------------------------ cat /tmp/3parvclogs/filesystems | grep -i vg | awk '{print $1}' | cut -d / -f 3 > /tmp/3parvclogs/vgs #------------------------------------------------------------------------# # Create base file which have the list of virtual volumes from 3par #------------------------------------------------------------------------# echo ' bctest ' > /tmp/3parvclogs/3parvvs #------------------------------------------------------------------------# # set & create log directory for today #------------------------------------------------------------------------# Current_time=`date +%Y_%b_%d_%H:%M` logdir=/tmp/3parvclogs/_3par_create_virtual_copy_LOGS/$Current_time mkdir -p $logdir #------------------------------------------------------------------------# # collect Luns & mount point status before run #------------------------------------------------------------------------# echo ' Collecting volume status before run .............' bdf > $logdir/bdf.b vgdisplay -v > $logdir/vgdisplay-v.b getwwid > $logdir/getwwid.b echo ' Contacting 3par storage nodes .............' ssh 3paradm@172.16.4.236 showvv > $logdir/showvv.b ssh 3paradm@172.16.4.236 showcpg > $logdir/showcpg.b ssh 3paradm@172.16.4.236 showvlun > $logdir/showvlun.b ssh 3paradm@172.16.4.224 showrcopy > $logdir/showrcopy.b #------------------------------------------------------------------------# # Stoping the replication #------------------------------------------------------------------------# echo ' Stopping Replication .............' ssh 3paradm@172.16.4.224 stoprcopy -stopgroups ssh 3paradm@172.16.4.224 showrcopy > $logdir/showrcopy.after.stop #------------------------------------------------------------------------# # Creating Snap volume read only #------------------------------------------------------------------------# dayhour=`date +%d_%H` for vv in ` cat /tmp/3parvclogs/3parvvs` do echo "Creating Read only snap for $vv ........." ssh 3paradm@172.16.4.236 createsv -ro -f $vv-$dayhour-VCRO $vv done #------------------------------------------------------------------------# # Re-starting replication #------------------------------------------------------------------------# echo ' Restarting Replication .............' ssh 3paradm@172.16.4.224 startrcopy sleep 10 ssh 3paradm@172.16.4.224 startrcopygroup VGORAARCH ssh 3paradm@172.16.4.224 startrcopygroup VGORACLE ssh 3paradm@172.16.4.224 startrcopygroup VGSHARE ssh 3paradm@172.16.4.224 showrcopy > $logdir/showrcopy.after.start echo ' Replication is successfully restarted ...... ' echo " " echo '/-----------------------------------------------------------------\' echo '| Enable Database from backup mode to Normal |' echo '| This script will continue and perform the remaning tasks |' echo '| even you put DB in normal mode ................... |' echo '\-----------------------------------------------------------------/' echo " " #------------------------------------------------------------------------# # Creating Snap volume Read write #------------------------------------------------------------------------# for vv in ` cat /tmp/3parvclogs/3parvvs` do echo "Creating read write snap for $vv ........." ssh 3paradm@172.16.4.236 createsv -f $vv-$dayhour-VCRW $vv-$dayhour-VCRO done #------------------------------------------------------------------------# # Presenting volumes to BC server #------------------------------------------------------------------------# for vv in ` cat /tmp/3parvclogs/3parvvs` do echo "Presenting volume $vv-$dayhour-VCRW to BC server" ssh 3paradm@172.16.4.236 createvlun -f $vv-$dayhour-VCRW auto BCTEST_172.16.4.164 done #------------------------------------------------------------------------# # Scaning new luns in unix box #------------------------------------------------------------------------# echo ' Scanning for new disk ......... ' ioscan -fnC disk for i in ` ioscan -fnNkC disk | grep -i NO_HW | grep -i 3PARdataVV | awk '{print $3}' ` do scsimgr -f replace_wwid -H $i done insf -eC disk #------------------------------------------------------------------------# # Importing new vgs #------------------------------------------------------------------------# echo ' Importing vgs ........... ' tar -xvf /tmp/3parvclogs/vgs.tar for i in ` cat /tmp/3parvclogs/vgs ` do vgimport -v -s -m /tmp/3parvclogs/$i.map $i vgchange -a y $i done #------------------------------------------------------------------------# # FSCK new filesystems #------------------------------------------------------------------------# echo ' Running File system check ....... ' for fs in ` cat /tmp/3parvclogs/filesystems | awk '{print $1}' ` do fsck -o -y full $fs done #------------------------------------------------------------------------# # Mounting new filesystems #------------------------------------------------------------------------# echo ' Mounting filesystems ....... ' #mount /dev/vgshare/lvshare /t24/share #mount /dev/vgstubs/lvstubs /t24/stubs #mount /dev/vgoracle/lvoracle /u01 #mount /dev/vgoradata/lvoradata /u02 # mount /dev/vgoraarch/lvoraarch /u03 mount /dev/vgbctest/lv2 /bctest2 mount /dev/vgbctest/lv1 /bctest1 #------------------------------------------------------------------------# # Collecting staus after script #------------------------------------------------------------------------# echo ' Collecing system status after script ....... ' bdf > $logdir/bdf.a vgdisplay -v > $logdir/vgdisplay-v.a getwwid > $logdir/getwwid.a echo ' Contacting 3par storage nodes for final status .............' ssh 3paradm@172.16.4.236 showvv > $logdir/showvv.a ssh 3paradm@172.16.4.236 showcpg > $logdir/showcpg.a ssh 3paradm@172.16.4.236 showvlun > $logdir/showvlun.a ssh 3paradm@172.16.4.224 showrcopy > $logdir/showrcopy.a echo " " echo " " echo ' ===================================================================' echo ' The script has been finished .......' ecvo " Kindly check $logdir directory for full logs and status ..... " echo ' ===================================================================' echo " "