You are not logged in or registered. Please login or register to use the full functionality of this Website SybaseTeam.Com...
Hello There, Guest! (LoginRegister) Remember Me? Current time: 08-30-2014, 07:27 AM
   Home  |  About Us  |  Sybase Training  |  Synergy  |  Consulting  |  Job Openings  |  Tech Videos  |  Rules and Disclaimer  |  Search
Post Reply 
Forum Tools
Sybase Database maintenance script
02-02-2010, 09:29 AM
Post: #1
Quote this message in a reply
Sybase Database maintenance script


This script performs DBCCs, transaction dumps, or database dumps for a
specified database.


#!/usr/bin/ksh
#-------------------------------------
# syb_maint
#
# Sybase database maintenance: perform DBCCs / log backups / db backups
#
# Parms: database, dump dir, mode (dump | tran_only | dbcc)
#
# Step 1: DBCCs (dbcc mode only)
# Step 2: Backup
#
# Output is routed to backup.log & dbcc.log
#-------------------------------------

if test $# -lt 3
then
echo " "
echo "usage:"
echo "------"
echo "syb_maint <mode (tran_only,dump,dbcc)>"
echo " "
echo " "

exit
fi

if test ! -d $2 ; then
echo " "
echo " Invalid path: "
echo $2
echo " "

exit
fi

if test ! -f /usr2/dumps/scripts/contact.txt ; then
echo " contact.txt file not found "
exit
fi

contact=`cat /usr2/dumps/scripts/contact.txt`
logfile1=/usr2/dumps/cronlogs/syb_maint/dbcc.log
logfile2=/usr2/dumps/cronlogs/syb_maint/backup.log

if test -f /tmp/syb_stop ; then
echo " ***** db stop detected ***** " >> $logfile1
exit
fi

echo "=============================" > /dev/null
echo $1 > /dev/null
echo "=============================" > /dev/null

if test "$3" = "dbcc" ; then

echo "Running dbcc step ..." > /dev/null

eval /apps/sybase/bin/isql -Sserver -I/apps/sybase/interfaces -Ujsmith -Pyankees << finis >> $logfile1

print '***** DBCC $1 **************************************'
go
use master
go
sp_dboption $1, "single user", true
go
use $1
go
dbcc checkdb ($1,skip_ncindex)
go
dbcc checkcatalog
go
dbcc checkalloc
go
checkpoint
go
use master
go
sp_dboption $1, "single user", false
go

quit

finis

# check output

if egrep "error|corrupt" $logfile1 | egrep -v "printed|TABLE|Checking" > /dev/null
then

echo "*** Errors found in DBCC log file."
rmail $techsupport@sybaseteam.com << endmsg
*** Errors found in DBCC log file
.
endmsg

fi


fi


echo "Running dump step ..." > /dev/null

eval /apps/sybase/bin/isql -Sserver -I/apps/sybase/interfaces -Ujsmith -Pyankees << finis2 >> $logfile2

print '***** DUMP $1 **************************************'
go

use master
go

exec sp_syb_maint $1, '$2', '$3'
go

quit

finis2

if grep "error|corrupt" $logfile2 > /dev/null
then

echo "*** Errors found in backup log file"
rmail $techsupport@sybaseteam.com << endmsg2
*** Errors found in backup log file
.
endmsg2

fi

echo "Sybase maintenance complete" > /dev/null


Find all posts by this user
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  How to get list of modified database objects (table) in sybase 15.0.3.0 bdvn_sudheer 7 2,415 07-19-2013 09:03 AM
Last Post: pinku.sybase
Smile Dataserver Health Checkout/QA Script sybanva 22 12,459 06-15-2013 09:07 AM
Last Post: dpssmita11
  SQL to display table size in database - all tables and the sizes amolkadu 2 5,221 11-13-2012 06:28 PM
Last Post: amol
  Script to report list of tables requiring reorg Kishor 1 4,654 10-06-2011 01:15 AM
Last Post: DerekAsirvadem
  Sybase SQL script to find out user database data and log size , data free , log free Joshi 3 12,819 05-03-2011 10:00 AM
Last Post: karim.attaleb@bnpparibas.com
  Process to manage transaction log using automated script Huseni Kathiria 1 3,184 12-24-2010 03:53 AM
Last Post: DerekAsirvadem
  Script to report non logged or minimally logged operation in sybase Kishor 2 5,476 08-04-2010 12:51 AM
Last Post: chandrashekhar
  Script to check whether a sybase database is offline or online Kishor 4 8,188 05-07-2010 06:49 AM
Last Post: Joshi
  Errorlog Monitoring Script for NT env in Perl sybanva 0 9,115 04-20-2010 07:28 AM
Last Post: sybanva

Options:
Forum Jump:


Contact Us | SybaseTeam | Disclaimer & Rules | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication