negu
(usa Outra)
Enviado em 27/04/2012 - 16:48h
Galera eu tenho o seguinte script:
#!/bin/bash
. /home/db2inst1/sqllib/db2profile
CFG_FILE="banco.cfg"
DESTINATION=`awk -F"=" '/^DESTINATION/ { print $2 }' $CFG_FILE`
QTD_DDL=`awk -F"=" '/^QTD_DDL/ { print $2 }' $CFG_FILE`
INTEGRITY_COPY=`awk -F"=" '/^INTEGRITY_COPY/ { print $2 }' $CFG_FILE`
DBNAME=`awk -F"=" '/^DBNAME/ { print $2 }' $CFG_FILE`
LOGDIR=`awk -F"=" '/^LOGDIR/ { print $2 }' $CFG_FILE`
LOGNEW=`ls -lah /var/log/watchdog/DB_Backup_"$DBNAME" | grep -i database | grep \`date +%d%m%y\`
LOGOLD=`ls -lah /var/log/watchdog/DB_Backup_"$DBNAME" | grep -i database | grep \`date -d yesterday +%d%m%y\`
BKP=`ls -lah $DESTINATION/FULL/ | grep -i "$DBNAME" | awk '{print $NF}'`
BKP_NEW=`ls -lah $DESTINATION/FULL/ | grep -i "$DBNAME" | grep \`date +%Y%m%d\` | cut -c50-110'
BKP_OLD=`ls -lah $DESTINATION/FULL/ | grep -i "$DBNAME" | grep \`date -d yesterday +%y%m%d\` | cut -c50-110'
LOG="/var/log/watchdog/DB_Backup_$DBNAME"
PATH_COPY=`awk -F"=" '/^PATH_COPY/ { print $2 }' $CFG_FILE`
QTD_FULL=`awk -F"=" '/^QTD_FULL/ { print $2 }' $CFG_FILE`
#VERIFICA SE DIRETORIO DE LOG EXISTE
echo "Checando existencia de diretorio de log......"
echo""
sleep 5
if [ ! -f "$LOGDIR" ] ; then
#echo "diretorio $LOGDIR nao existe"
#else
echo "1"
exit 1
echo "O diretorio $LOGDIR Existe"
fi
echo ""
#CHECA SE LOG EXISTE
echo "Checando existencia de logs......."
echo ""
sleep 5
if [ ! -f $LOG/$LOGNEW ] && [ ! -f $LOG/$LOGOLD ]; then
#echo "Exibindo arquivo de log atual: $LOGNEW"
else
echo "Arquivo de log nao encontrado"
echo "2"
exit 2
fi
echo ""
#CHECA DIRETORIO DO BACKUP EXISTE
echo "Checando existencia do diretorio de Backup $PATH_COPY........"
echo ""
sleep 5
if [ ! -f $PATH_COPY ] ; then
#echo "Diretorio de backup $PATH_COPY Existe"
#else
echo "Diretorio de backup $PATH_COPY Nao Existe"
echo "3"
exit 3
fi
#CHECHA SE EXISTE BACKUP
echo "Checando Quantidade de backup FULL.......: $QTD_FULL "
echo ""
echo "Listando arquivos..................."
sleep 5
echo ""
echo "$BKP"
echo "Buscando Ultimo backup........"
echo ""
sleep 5
if [ ! -f "$BKP_NEW" ] && [ ! -f "$PATH_COPY/$BKP_NEW" ] ; then
#echo "Exibindo Backup mais atual e Backup de ontem: $BKP_NEW" | echo "Backup de ontem: $BKP_OLD"
#else
echo "Nao foi encontrado nehum backup"
echo "4"
exit 4
fi
ai eu rodo ele e da um erro, estou rodando com bash -x
segue saida:
++ export LD_LIBRARY_PATH
++ '[' -f /home/db2inst1/sqllib/userprofile ']'
++ . /home/db2inst1/sqllib/userprofile
+ CFG_FILE=banco.cfg
++ awk -F= '/^DESTINATION/ { print $2 }' banco.cfg
+ DESTINATION=/db_local/backup/asset
++ awk -F= '/^QTD_DDL/ { print $2 }' banco.cfg
+ QTD_DDL=14
++ awk -F= '/^INTEGRITY_COPY/ { print $2 }' banco.cfg
+ INTEGRITY_COPY=Y
++ awk -F= '/^DBNAME/ { print $2 }' banco.cfg
+ DBNAME=BANCO
++ awk -F= '/^LOGDIR/ { print $2 }' banco.cfg
+ LOGDIR=/var/log/watchdog
+ grep -i database
+ grep '`date' -d yesterday '+%d%m%y`'
++ grep -i database
grep: unknown directories method
+++ date +%d%m%y
++ ls -lah /var/log/watchdog/DB_Backup_BANCO
++ grep 270412
++ LOGOLD=
+ LOGNEW=ls
+ -lah /var/log/watchdog/DB_Backup_ASSET
./backup_check.sh: line 11: -lah: command not found
++ ls -lah /db_local/backup/asset/FULL/
++ grep -i ASSET
++ awk '{print $NF}'
+ BKP=banco.0.db2inst1.NODE0000.CATN0000.20120426212536.001
./backup_check.sh: line 17: unexpected EOF while looking for matching `''
./backup_check.sh: line 82: syntax error: unexpected end of file
[root@AUTCTX04RJORP scripts]#