Sponsored Content
Special Forums UNIX and Linux Applications No alarm triggered when backup tape is full Post 302618051 by methyl on Tuesday 3rd of April 2012 01:38:36 PM
Old 04-03-2012
I couldn't reformat the original post of the script because it contains too much extraneous HTML.

Here is the original script minus any surplus commented-out lines and indented for readability. This is not a corrected script, just a diagnostic so we can read it!

Code:
#!/bin/sh
#set -x

VERSION="Version: 1.06"
######################
# Choose the HOME dir
######################
HOME=/export/home/provadm
BINDIR=$HOME/bin
LOGDIR=$HOME/log
SCRDIR=$HOME/script
CONFDIR=$HOME/config
TEMP=$HOME/temp
#######################
# Choose the BACKUP dir
#######################
BACKUPDIR=/data
newhost=`hostname |sed 's/LIV_//'| sed 's/_01//'`
TAPE_DEVICE=/dev/rmt/0
TAPE_DEVICE_APPEND=/dev/rmt/0n
datestr=`date +%d-%m-%Y`
timestr=`date +%H:%M:%S`
event_day=`/bin/date +%Y%m%d`
currdate=`$HOME/bin/lastdate +1 | awk '{printf "%s",substr($0,1,6)}'`
LOG=$LOGDIR/TAPE/$currdate/tape_bk_$event_day.log
TMP_LOG=$TEMP/tape_backup.tmp
# Format yyyymmdd
yest01=`$BINDIR/lastdate 1 | /bin/awk '{print $1}'`
# Format MMM
mm=`$BINDIR/lastdate 1 | /bin/awk '{print $2}' | cut -c1-3`
# Format DD
dd=`$BINDIR/lastdate 1 | /bin/awk '{print $1}' | cut -c7-8`
# Format YYYY
yyyy=`$BINDIR/lastdate 1 | /bin/awk '{print $1}' | cut -c1-4`
# Format yyyymm
yestmonth01=`$BINDIR/lastdate 1 | /bin/awk '{print $1}' | cut -c1-6`
# ==============
# Date and Month
# ==============
REP_MONTH=`date "+%Y%m"`
REP_DATE=`date "+%Y%m%d"`
FIRST_DAY=`$BINDIR/lastdate | /bin/awk '{print $1}' | cut -c7-8`

chktape()
{
status=`/bin/mt -f $TAPE_DEVICE_APPEND status | grep 'sense' | awk '{print substr($1,1,5)}'`
}

tarcmd()
{
# Check the $TMP_LOG file if exists, if yes remove the file
if [ -f $TMP_LOG ]; then
	rm $TMP_LOG
fi
#/data1/ACCESS
#All Servers
/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/ACCESS/$yestmonth01/*$yest01*.tar.Z >> $LOG 2>>$TMP_LOG

if [ $FIRST_DAY = "01" ]; then
	#/data1/BACKUP
	# All Servers 
	/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/BACKUP/$yestmonth01/*_$yestmonth01.* >> $LOG 2>>$TMP_LOG
fi

#/data/BACKUP
# LNPDB, RPT
#/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/BACKUP/$yestmonth01/*$yest01*.tar.gz >> $LOG 2>>$TMP_LOG

#/data1/SYS
# All Servers
/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/SYS/$yestmonth01/$yest01*.Z >> $LOG 2>>$TMP_LOG

#/data/TDR2
# PGW, RPT
/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/TDR2/$yestmonth01/$yest01*.*.TDR2.Z >> $LOG 2>>$TMP_LOG

# /data/TDR2_M
# PGW
/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/TDR2_M/$yestmonth01/$yest01*.TDR2_M.Z >> $LOG 2>>$TMP_LOG

# /data/IPMP
# LSMS, PGW, LNPDB, RPT
/bin/tar cvf $TAPE_DEVICE_APPEND $BACKUPDIR/IPMP/$yestmonth01/IPMP.log.$yest01.*.Z >> $LOG 2>>$TMP_LOG
}

# Main
status=""
chktape
if [ "$status" = "sense" ]
then
	# Got tape inside
	# Clear alarm
	$SCRDIR/gen_alarm.sh 21 0 "$newhost No Tape detected"
	# Start doing backup
	echo "" | /bin/tee -a $LOG
	echo "Tape Backup Start ($datestr $timestr) ..." | /bin/tee -a $LOG
	echo "" | /bin/tee -a $LOG
	tarcmd >> $LOG
	if [ $? -ne 0 ]
	then
		# Put the stderr message generated from tarcmd() into the $LOG file
		cat $TMP_LOG >> $LOG
		echo "" | /bin/tee -a $LOG
		echo "Tape Backup was failed" >> $LOG
		$SCRDIR/gen_alarm.sh 23 1 "$newhost Tape backup error"
	else
		# Put the stderr message generated from tarcmd() into the $LOG file
		cat $TMP_LOG >> $LOG
		echo "" | /bin/tee -a $LOG
		echo "Tape Backup Succeeded" >> $LOG
		$SCRDIR/gen_alarm.sh 23 0 "$newhost Tape backup error"
	fi

	EOT=`cat $TMP_LOG | grep 'tar: write error: unexpected EOF' | wc -l`
	if [ $EOT -ge 1 ]; then
		# Tape Full
		# Raise alarm
		$SCRDIR/gen_alarm.sh 22 1 "$newhost Tape full"
		echo "" | /bin/tee -a $LOG
		echo "Tape Full ($datestr $timestr) ..." | /bin/tee -a $LOG
		echo "" | /bin/tee -a $LOG
	else
		# Tape NOT Full
		# Clear alarm
		$SCRDIR/gen_alarm.sh 22 0 "$newhost Tape full"
	fi

	echo "" | /bin/tee -a $LOG
	datestr=`date +%d-%m-%Y`
	timestr=`date +%H:%M:%S`
	echo "Tape Backup End ($datestr $timestr) ..." | /bin/tee -a $LOG
else
	# No tape inside
	# Raise alarm
	$SCRDIR/gen_alarm.sh 21 1 "$newhost No Tape detected"
	echo "" | /bin/tee -a $LOG
	echo "Tape Backup Fail ($datestr $timestr) ..., unable to find tape" | /bin/tee -a $LOG
	echo "" | /bin/tee -a $LOG
fi

# Housekeep the tape_bk_yyyymmdd.log
hk_month=`$BINDIR/lastdate 121 | /bin/awk '{print $1}' | /bin/cut -c1-6`
\rm $LOGDIR/TAPE/$currdate/tape_bk_$hk_month*.log
find $TEMP -name 'tape_backup.tmp' -exec rm {} \;


Last edited by methyl; 04-03-2012 at 02:46 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Mounting DLT tape and to backup file to tape

Hi there: I'm new here Can anyone help me: I have DS15 Alpha server : Unix 5.1B Now i need to connect a DLVT VS80 1U Rackmount Tape Drive unit. What is the exact comman to mount the DLTape IV?? How do i make backuo @ copy file to the tape? Thanx to all (0 Replies)
Discussion started by: ayzeayem
0 Replies

2. UNIX for Dummies Questions & Answers

Check backup file size on backup tape

Hi, I performed backup on tape and I want to append more files to my previous backup on the same backup tape. But before I do that I need to know the backup file size of the first backup I performed so that I know the available size on the backup tape. Can someone help me what command I will use... (0 Replies)
Discussion started by: ayhanne
0 Replies

3. SCO

Backup to SCSI Tape Backup aborts

I am trying to make a full backup of my system using the cpio command. The Tape Unit is a SCSI DDS. The process started fine but after about 30 minutes, it just stopped and showed the following message: 1755 Signal 31 - Core dumped Any idea of what is causing this and how to fix it? ... (4 Replies)
Discussion started by: zionpc
4 Replies

4. UNIX for Dummies Questions & Answers

System full backup to tape

hi, Recently, I had receive one system. it's run on the unix tru64 server. I looking some log files when i know don't work few months age system backup to tape. Below error: INFO:Tape backups to tape tape0 starting for backup list: slot2:/disk4 Backup Command Variable... (0 Replies)
Discussion started by: Tlg13team
0 Replies

5. Solaris

Full backup and Restore

Dear All ; first how are you every body I'm just subscribed in your forum and i hope i found what i searched for along time . I'm not a Solaris specialist but i read more to build a Network Management Station depends on Solaris as OS and it is working good now . my problem is how to perform... (16 Replies)
Discussion started by: Basha
16 Replies

6. Solaris

full system backup

I have unix server with OS 5.8 ,,, I tried ufsdump 0ua -f /dev/rmt/0 / to perform full system backup on tape but I failed could any one give a procedure for full system backup on solaris machine using tapes??? (1 Reply)
Discussion started by: mm00123
1 Replies

7. Red Hat

Full OS-Backup

Hi, our redhat farm is growing (rhel 3 4 5) and the only backup we do is an incremental filesystembackup, which makes it very hard to restore the complete os is there a solution for a complete os-backup to a network server, like nim in aix, an the possibility to restore the whole red hat... (1 Reply)
Discussion started by: funksen
1 Replies

8. UNIX for Dummies Questions & Answers

incremental and full backup.. please help me

Hi, i'm new here(and a newbie) and i need some help with a project. I need to write a script for an incremental backup (this must be executed every day at 24:00) and a full backup (executed once a month) for etc/var/home directories. Can someone please help me with this? And a small explanation of... (9 Replies)
Discussion started by: bender-alex
9 Replies

9. Homework & Coursework Questions

incremental or full backup ???

Hi. Can someone tell me if the following script that i have made is a script for INCREMENTAL BACKUP or FULL BACKUP. My teacher told me that is doing an FULL BACKUP. • find /etc /var /home -newer /backups/.backup_reference > /backups/.files_to_archive • touch /backups/.backup_reference • tar... (1 Reply)
Discussion started by: bender-alex
1 Replies

10. AIX

Nimol: full backup,is possible?

I have a NIMOL(nim on linux) server working. It do a full backup of my rootvg with those commands nimol_config -r -L old-2018 nimol_config -m /usr/bin/ssh -C -L new-2018 nimol_backup -c ibmaix -L new-2018 My question is: is possible like hp-ux do with "make_tape_recovery" a FULL... (1 Reply)
Discussion started by: Linusolaradm1
1 Replies
All times are GMT -4. The time now is 05:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy