Script mksysb sur machine dans un autre réseau (script local)
# cat /users/exploit/scripts/save_mksysb.ksh
#!/usr/bin/ksh
DATE=`date '+%y%m%d'`
HOSTNAME=`uname -n`
DIR="/Nim_Master/Ressources"
rm -f ${DIR}/mksysb_${HOSTNAME}*.old
for i in `ls mksysb_${HOSTNAME}* | grep -v log`
do
mv ${i} ${i}.old
done
#mksysb '-e' '-i' '-X' '-A' ${DIR}/mksysb_${HOSTNAME}_${DATE} > ${DIR}/mksysb_${HOSTNAME}_${DATE}.log 2>&1
Script mksysb sur machine dans un autre réseau (appel script local ci-dessus)
# cat /users/exploit/scripts/save_dmz_mksysb.ksh
#!/bin/ksh
function save
{
set -x
# Variables settings
typeset -u UMAC=$machine
typeset -l LMAC=$machine
F=`date '+%y%m%d'`
IMADIR=/Nim_Master/Ressources
DIR=/users/exploit/log
FILENAME=mksysb_${LMAC}_${F}
# Test connexion
ping -c1 $LMAC
if [ "$?" -eq 0 ]
then
# Define mksysb nim object
# nim -o remove mksysb_$LMAC
# nim -o define -t mksysb -a server=master -a location=$IMADIR/mksysb_$LMAC -a mk_image=yes -a source=$LMAC mksysb_$LMAC
ssh $LMAC /export/sav_mksysb.ksh
RC=$?
# On recupere la log mksysb
scp $LMAC:/export/images/log/mksysb_${LMAC}_${F} ${DIR}/mksysb_${LMAC}_${F}
# grep "Backup Completed Successfully" /export/images/log/mksysb_${LMAC}_${F}
if [ "$RC" -eq 0 ]
then
echo `date '+%d/%m/%Y %H:%M:%S'` "Sauvegarde de $LMAC est OK" > $IMADIR/logs/$LMAC.log
scp $LMAC:/export/images/mksysb_${LMAC}_${F} $IMADIR/mksysb_${LMAC}_${F}
$RCSCP=$?
if [ "$RCSCP" -eq 0 ]
then
ssh $LMAC rm /export/images/mksysb_${LMAC}_${F}
else
echo "Probleme de recuperation du fichier mksysb" >> $IMADIR/logs/$LMAC.log
fi
else
echo `date '+%d/%m/%Y %H:%M:%S'` "Probleme de Sauvegarde de $LMAC Return-Code : "$RC >> $IMADIR/logs/$LMAC.log
fi
else
echo "Probleme de connection a $LMAC " >$IMADIR/logs/$LMAC.log
fi
}
# Main
# Choix machine
if [ "$#" -eq 1 ]
then
machine=$1
save
else
for machine in $(lsnim|grep standalone|awk '{print $1}')
do
save
sleep 600
done
fi
Aucun commentaire:
Enregistrer un commentaire