I’ve been a lot of linux work lately. We had an issue in the linux cluster if the volumes migrate to other servers in the cluster than where the backup server is that they either skip the volume or perform a full back of the volume. I didn’t see much out there about what others had done to do this, so I threw this together.
here is a script I put together to migrate a set group of volumes back to the server if they are not already mounted:
—beginning of script————
#!/bin/bash
#Enter the volumes that are to be migrated to this server
# if you need more than 10 also add an echo command as listed below (echo $VXX >>$TMPDIR/vars.$RAND1)
V1=
V2=
V3=
V4=
V5=
V6=
V7=
V8=
V9=
V10=
#Get the date
DATE=`time ‘+%b %d %T’`
#set temp directory
TMPDIR=/tmp
#set counting varialbe
NVC=1
# Get the hostname
HOST=`hostname`
# generate a random key
RANDOM=`date ‘+%s’`
RAND1=$[($RANDOM % 999) + 1]
echo $V1 >$TMPDIR/vars.$RAND1
echo $V2 >>$TMPDIR/vars.$RAND1
echo $V3 >>$TMPDIR/vars.$RAND1
echo $V4 >>$TMPDIR/vars.$RAND1
echo $V5 >>$TMPDIR/vars.$RAND1
echo $V6 >>$TMPDIR/vars.$RAND1
echo $V7 >>$TMPDIR/vars.$RAND1
echo $v8 >>$TMPDIR/vars.$RAND1
echo $v9 >>$TMPDIR/vars.$RAND1
echo $V10 >>$TMPDIR/vars.$RAND1
sed ‘/^$/d’ $TMPDIR/vars.$RAND1 > $TMPDIR/vars1.$RAND1
#number of volume variables
NV=`wc -l $TMPDIR/vars1.$RAND1 |awk ‘{print $1}’`
cluster status |grep $HOST | awk ‘{print $1}’
while [ $NVC -le $NV ]
do
LINE=`head -$NVC $TMPDIR/vars1.$RAND1 | tail -1`
VTEST=`cluster status |grep $HOST | awk ‘{print $1}’ |grep $LINE`
if [ “$(echo $LINE)” == “$(echo $VTEST)” ]; then
echo “$DATE already mounted on this server… skipping $LINE”
else
echo “$DATE not mounted on this server.. .need to migrate $LINE”
cluster migrate $LINE $HOST
sleep 30
fi
(( NVC++))
done
#clean up temp files
rm $TMPDIR/*.$RAND1
————–end of script————-
Leave a Reply