DB2 LUW: Generic backup script to filesystem

################################################################
#USAGE: The below script is to take backup to local filesystem
# It emails SUCCESS/ERROR details
# INCLUDE LOGS backup option: No need to for this, it is by default
#Author: Ravi
################################################################
#!/bin/sh
BACKDIR=/tmp
DBNAME=RAVIDB
EMAILDIST=”email@email.com”

#Backup mode. You just have to change this to ONLINE/ONLINE INCREMENTAL/OFFLINE
#BMODE=
#BMODE=”ONLINE INCREMENTAL”
BMODE=”ONLINE”

db2 backup db $DBNAME $BMODE to $BACKDIR WITHOUT PROMPTING
if [ “$?” -eq “0” ]
then
echo “…You can write email body here!…” | mailx -s “SUCCESS:$BMODE Backup of $DBNAME ” $EMAILDIST
exit 0
else
echo “…You can write email body here!…” | mailx -s “ERROR:$BMODE Backup of $DBNAME” $EMAILDIST
exit 1
fi

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: