script vault.sh

#!/bin/bash
clear
BIN=/bin
LOG=/root/scripts/vault.log

#functions
function filer {
echo checking $FILER
if $BIN/ping -c 2 -q $FILER > /dev/null 2>&1
then
:
else
$FILER unreachable - exiting
exit
fi
}

function check {
echo "FUNCTION CHECK"
length=`ssh kp7m1 options snapvault.access|awk '{print $2}'`
if [ $length == "legacy" ]
then
ssh $SF options snapvault.access host=$DF
else
host=`echo $length|cut -f2 -d"="`
if echo $host|grep $DF > /dev/null
then
echo "$DF has access"
else
length=${host},$DF
echo "snapvault access for $length "
ssh $SF options snapvault.access host=${length},$DF
ssh $SF options snapvault.access
fi
fi
}

#determine filers
echo "set up snapvaultrelation between two qtrees,"
echo "source qtree does not have to exist,"
echo "source volume has to exist."
echo -n "sourcefiler : " ; read SF ; FILER=$SF
filer
echo -n "destinationfiler : " ; read DF ; FILER=$DF
filer
#check access
check
#determine volume/qtree
echo -n "enter source qtreename (absolute pathname) : "
read ST
SV=`echo $ST | cut -f3 -d"/"`
SQName=`echo $ST | cut -f4 -d"/"`
echo "Volume $SV - qtree $SQName"
echo "checking $SV"
if ssh $SF vol size $SV | grep -i flexible > /dev/null 2>&1
then
echo "Ok"
else
echo "$SV not found, exiting"
exit
fi
echo -n "destination qtreename (absolute pathname) : "
read DT
DV=`echo $DT | cut -f3 -d"/"`
DQName=`echo $DT | cut -f4 -d"/"`
echo "Volume $DV - qtree $DQName"
echo "checking $DV"
if ssh $DF vol size $DV | grep -i flexible > /dev/null 2>&1
then
echo "Ok"
else
echo "$DV not found, exiting"
exit
fi

echo -n "number of snapshots to retain on ${SF}-$SV : "
read SVR
echo -n "number of snapshots to retain on ${DF}-$DV : "
read DVR

echo "1 $DF snapvault start -S ${SF}:$ST ${DF}:$DT"
date >> $LOG
ssh $DF snapvault start -S ${SF}:$ST ${DF}:$DT >> $LOG 2>&1

echo "2 $SF snapvault snap sched ${SV} ${SV}${SQName} ${SVR}@0-23"
date >> $LOG
ssh $SF snapvault snap sched ${SV} ${SV}${SQName} ${SVR}@0-23 >> $LOG 2>&1

echo "3 $DF snapvault snap sched -x ${DV} ${SV}${DQName} ${DVR}@0-23"
date >> $LOG
ssh $DF snapvault snap sched -x ${DV} ${SV}${DQName} ${DVR}@0-23 >> $LOG 2>&1
echo "creating snapshot schedule for $SV"

echo "4 $SF snapvault snap create ${SV} ${SV}${SQName}"
date >> $LOG
ssh $SF snapvault snap create ${SV} ${SV}${SQName} >> $LOG 2>&1

echo "5 $DF snapvault status | grep $ST"
date >> $LOG
ssh $DF snapvault status | grep $ST >> $LOG 2>&1
ssh $DF snapvault status
echo " "

echo "Done!"
echo "Check logfile : $LOG"

This entry was posted in netapp, scripts. Bookmark the permalink.

Comments are closed.