Topic
  • 2 replies
  • Latest Post - ‏2013-01-08T06:18:01Z by SystemAdmin
SystemAdmin
SystemAdmin
13279 Posts

Pinned topic ISD 6.3 + IBM DB2 managed on Redhat 6.3 - Required rpm, BackupScript.

‏2013-01-07T09:26:42Z |
Required rpm

yum install openssh compat-libstdc++-33.i686 glibc.i686 libgcc.i686 unzip libaio pam.i686 bind-utils net-tools libstdc++.i686 libuuid.i686 compat-expat1.i686 zlib.i686 expat.i686 libstdc++.x86_64 compat-libstdc++-33.x86_64

BackupScript (For Email Program used perl script - sendEmail)

#!/bin/bash
#
  1. Autor: Lagutin R.A.
  2. Contact mail: R.Lagutin@ttk.ru
#
  1. IBM Systems Director Script for backup all data (include Managed IBM DB2 database)
#
#
  1. Variables
#

  1. Date format:
ISD_DATE=$(date +%Y.%m.%d_%H.%M.%S_%N) # Current date

  1. Hostname
ISD_HOST=$(hostname -s) # Short name
ISD_DOM=$(hostname -d) # Domain name
ISD_IP=$(hostname -i) # IP

  1. Working file
ISD_WORK_DIR=/opt/ibm/director/bin/ # ISD working dir
ISD_LOGFILE=/var/log/isd_backup_$ISD_DATE.log # Log file

  1. Backup file
ISD_BACKUP_DIR=/opt/ibm/director/backup/ # ISD backup dir
ISD_TARGET_DIR=/opt/ibm/director/backup/$ISD_DATE # ISD target dir
ISD_TARGET_FILE=/opt/ibm/director/backup/isd_backup_$ISD_DATE.tgz # ISD target file

  1. Mail
ISD_MAILFROM="ISD Monitoring <$ISD_HOST@ttk.ru>" # Mailfrom
ISD_MAILTO="admin@admin.ru" # Delimiter space
ISD_MAILSUB= # Mail subscription (not change)
ISD_MAILSERVER="localhost:25" # Example mail.admin.ru:25 or localhost:25
ISD_MAILCHARSET="message-charset=UTF-8" # Mail charset

  1. GNU Command
ISD_RM=/bin/rm
ISD_TAR=/bin/tar
ISD_FIND=/bin/find
ISD_MAILER=/usr/local/bin/sendEmail # Sendmail program. /usr/bin/perl

  1. Backup rotation min
ISD_ROT=180 # Delete backup file old min

  1. Backup pars
ISD_PARS="Command completed successfully" # ISD pars string

  1. Return values
ISD_STATE= # ISD current state

  1. Color
SETCOLOR_BLUE="echo -en \\033[1;34m"
SETCOLOR_WHITE="echo -en \\033[0;39m"
SETCOLOR_RED="echo -en \\033[0;31m"
SETCOLOR_CYAN="echo -en \\033[0;36m"
SETCOLOR_MAGENTA="echo -en \\033[1;31m"
SETCOLOR_LIGHTRED="echo -en \\033[1;31m"
SETCOLOR_YELLOW="echo -en \\033[1;33m"

#
  1. Functions
#

ISD_VAR() {
echo -e
$SETCOLOR_BLUE; echo -en 'IBM Systems Director Script for backup all data (include Managed IBM DB2 database)';$SETCOLOR_WHITE; echo -e
echo -e
echo -en "DATE: "; $SETCOLOR_YELLOW; echo -en $ISD_DATE; $SETCOLOR_WHITE; echo -e
echo -en "EXEC: "; $SETCOLOR_YELLOW; echo -en $0; $SETCOLOR_WHITE; echo -e
echo -e
echo -en "HOSTNAME: "; $SETCOLOR_YELLOW; echo -en $ISD_HOST; $SETCOLOR_WHITE; echo -e
echo -en "DOMAIN: "; $SETCOLOR_YELLOW; echo -en $ISD_DOM; $SETCOLOR_WHITE; echo -e
echo -en "IP: "; $SETCOLOR_YELLOW; echo -en $ISD_IP; $SETCOLOR_WHITE; echo -e
echo -e
echo -en "LOGFILE: "; $SETCOLOR_YELLOW; echo -en $ISD_LOGFILE; $SETCOLOR_WHITE; echo -e
echo -en "TARGET FILE: "; $SETCOLOR_YELLOW; echo -en $ISD_TARGET_FILE; $SETCOLOR_WHITE; echo -e
echo -e
echo -en "ROTATION MIN: "; $SETCOLOR_YELLOW; echo -en $ISD_ROT; $SETCOLOR_WHITE; echo -e
echo -e
}

ISD_ROOT() {

if ; then

echo -e
echo -e 'Usage: '$0' must be run as root' 1>&2

exit 1

fi

}

ISD_START() {

local ISD_START_VAR=$ISD_WORK_DIR'smstart'

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_START_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_START_VAR

}

ISD_STOP() {

local ISD_STOP_VAR=$ISD_WORK_DIR'smstop'

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_STOP_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_STOP_VAR

}

ISD_STATUS() {

# Smstatus error code
# 0: Active: The process is fully active and ready for work.
# 1: Starting: The process is starting but is not yet ready for work.
# 2: Ending: The process was requested to end but has not yet ended.
# 3: Inactive: The process has ended or was never started.
# 4: Error: The process has ended abnormally.
# 7: Incorrect parameters: Incorrect parameters were entered.

local ISD_STATUS_VAR=$ISD_WORK_DIR'smstatus'

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_STATUS_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_STATUS_VAR
ISD_STATE=$?

}

ISD_BACKUP() {

local ISD_BACKUP_VAR=$ISD_WORK_DIR'smsave -targetDir '$ISD_TARGET_DIR

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_BACKUP_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_BACKUP_VAR

}

ISD_TAR() {

local ISD_TAR_VAR=$ISD_TAR' -czf '$ISD_TARGET_FILE' '$ISD_TARGET_DIR

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_TAR_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_TAR_VAR

}

ISD_TAR_TEST() {

local ISD_TAR_TEST_VAR=$ISD_TAR' -tzf '$ISD_TARGET_FILE

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_TAR_TEST_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_TAR_TEST_VAR

}

ISD_CLEAN() {

local ISD_CLEAN_VAR='rm -rf '$ISD_TARGET_DIR

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_CLEAN_VAR;
$SETCOLOR_WHITE;
echo -e

$ISD_CLEAN_VAR

}

ISD_ROT() {

# Print files *.tgz old 180 min
# find /target/backup -type f -mmin +180 -name '*.tgz' -print

# Delete files *.tgz old 180 min
# find /target/backup -type f -mmin +180 -name '*.tgz' -delete

local ISD_ROT_VAR1="find $ISD_BACKUP_DIR -type f -mmin +$ISD_ROT -name '*.tgz' -print"
local ISD_ROT_VAR2="find $ISD_BACKUP_DIR -type f -mmin +$ISD_ROT -name '*.tgz' -delete"

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en $ISD_ROT_VAR2;
$SETCOLOR_WHITE;
echo -e

eval $ISD_ROT_VAR1
eval $ISD_ROT_VAR2

}

ISD_MAIL() {

echo -e
echo -en "Exec: "; $SETCOLOR_YELLOW;
echo -en "Send mail";
$SETCOLOR_WHITE;
echo -e

# rm -f $ISD_LOGFILE
if -e $ISD_LOGFILE ; then

if ; then

ISD_MAILSUB="$ISD_HOST. Backup exec: SUCCESS"

else

ISD_MAILSUB="$ISD_HOST. Backup exec: FAILED"

fi

# echo -en "MAILFROM: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILFROM; $SETCOLOR_WHITE; echo -e
# echo -en "MAILTO: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILTO; $SETCOLOR_WHITE; echo -e
# echo -en "MAILSUB: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILSUB; $SETCOLOR_WHITE; echo -e
# echo -en "MAILSERVER: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILSERVER; $SETCOLOR_WHITE; echo -e
# echo -en "MAILCHARSET: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILCHARSET; $SETCOLOR_WHITE; echo -e

cat $ISD_LOGFILE | sed -r "s/\x1B[(0-9{1,2}(;0-9{1,2})?)?K//g" | "$ISD_MAILER" \
-f "$ISD_MAILFROM" \
-t "$ISD_MAILTO" \
-u "$ISD_MAILSUB" \
-s "$ISD_MAILSERVER" \
-o "$ISD_MAILCHARSET" \

else

ISD_MAIL_ERR="File not found: $ISD_LOGFILE"
ISD_MAILSUB="$ISD_HOST. Exec: $ISD_MAIL_ERR"

# echo -en "MAILFROM: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILFROM; $SETCOLOR_WHITE; echo -e
# echo -en "MAILTO: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILTO; $SETCOLOR_WHITE; echo -e
# echo -en "MAILSUB: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILSUB; $SETCOLOR_WHITE; echo -e
# echo -en "MAILSERVER: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILSERVER; $SETCOLOR_WHITE; echo -e
# echo -en "MAILCHARSET: "; $SETCOLOR_YELLOW; echo -en $ISD_MAILCHARSET; $SETCOLOR_WHITE; echo -e

"$ISD_MAILER" \
-f "$ISD_MAILFROM" \
-t "$ISD_MAILTO" \
-u "$ISD_MAILSUB" \
-s "$ISD_MAILSERVER" \
-o "$ISD_MAILCHARSET" \
-m "$ISD_MAIL_ERR"
fi

}

#
  1. Main
#

  1. ISD_VAR # Show var
  2. ISD_ROOT # Root check
  3. ISD_START # IBM Systems Director Start service
  4. ISD_STOP # IBM Systems Director Stop service
  5. ISD_STATUS # IBM Systems Director Status service
  6. ISD_BACKUP # IBM Systems Director Backup. ISD service must be stopped!
  7. ISD_TAR # Archive
  8. ISD_TAR_TEST # Archive test
  9. ISD_CLEAN # Delete temp files
  10. ISD_ROT # Backup rotation
  11. ISD_MAIL # Send mail

#
exec &> >(tee -a $ISD_LOGFILE)
#

#

case $1 in
start)

ISD_VAR
ISD_ROOT
$SETCOLOR_RED; echo -en "ISD Start"; $SETCOLOR_WHITE; echo -e
ISD_START
exit 0

;;

stop)

ISD_VAR
ISD_ROOT
$SETCOLOR_RED; echo -en "ISD Stop"; $SETCOLOR_WHITE; echo -e
ISD_STOP
exit 0

;;

status)

ISD_VAR
ISD_ROOT
$SETCOLOR_RED; echo -en "ISD Status"; $SETCOLOR_WHITE; echo -e
ISD_STATUS
exit 0

;;

backup)

ISD_VAR
ISD_ROOT
$SETCOLOR_RED; echo -en "ISD Backup"; $SETCOLOR_WHITE; echo -e
ISD_STATUS

case "$ISD_STATE" in
0)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Active: The process is fully active and ready for work.";
$SETCOLOR_WHITE; echo -e

ISD_STOP
ISD_BACKUP
ISD_TAR
ISD_CLEAN
ISD_ROT
ISD_START

ISD_TAR_TEST

;;
1)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Starting: The process is starting but is not yet ready for work.";
$SETCOLOR_WHITE; echo -e

#ISD_STOP
#ISD_BACKUP
#ISD_TAR
#ISD_CLEAN
#ISD_ROT
#ISD_START

#ISD_TAR_TEST

;;
2)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Ending: The process was requested to end but has not yet ended.";
$SETCOLOR_WHITE; echo -e

#ISD_STOP
#ISD_BACKUP
#ISD_TAR
#ISD_CLEAN
#ISD_ROT
#ISD_START

#ISD_TAR_TEST

;;
3)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Inactive: The process has ended or was never started.";
$SETCOLOR_WHITE; echo -e

#ISD_STOP
ISD_BACKUP
ISD_TAR
ISD_CLEAN
ISD_ROT
#ISD_START

ISD_TAR_TEST

;;
4)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Error: The process has ended abnormally.";
$SETCOLOR_WHITE; echo -e

#ISD_STOP
#ISD_BACKUP
#ISD_TAR
#ISD_CLEAN
#ISD_ROT
#ISD_START

#ISD_TAR_TEST

;;
7)
echo -en "ISD status: "; $SETCOLOR_YELLOW;
echo -en "Incorrect parameters: Incorrect parameters were entered.";
$SETCOLOR_WHITE; echo -e

#ISD_STOP
#ISD_BACKUP
#ISD_TAR
#ISD_CLEAN
#ISD_ROT
#ISD_START

#ISD_TAR_TEST

;;

esac

ISD_MAIL
exit 0

;;

*)

ISD_ROOT
ISD_VAR
echo 'Usage: '$0' {start|stop|status|backup}'
echo -e

esac

exit 0
Updated on 2013-01-08T06:18:01Z at 2013-01-08T06:18:01Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    13279 Posts

    Re: ISD 6.3 + IBM DB2 managed on Redhat 6.3 - Required rpm, BackupScript.

    ‏2013-01-08T01:42:47Z  
    UPD: BackupScript

    Desc: IBM Systems Director Script for backup all data (include Managed IBM DB2 database)

    Test date: 08.01.2013

    Platform: VMware VM Workstion 9.0.1
    OS: RedHat Enterprise Linux 6.3 x64
    CPU: 2
    RAM: 3 GB
    DISK1 30 GB

    Application: IBM Systems Director 6.3.2
    DB: DB2 managed

    --
    Backupscript uses to send mail notification program sendemail: http://caspian.dotconf.net/menu/Software/SendEmail/
  • SystemAdmin
    SystemAdmin
    13279 Posts

    Re: ISD 6.3 + IBM DB2 managed on Redhat 6.3 - Required rpm, BackupScript.

    ‏2013-01-08T06:18:01Z  
    tested run through cron
    In the script, there are some changes

    example cron:

    0 6 * * * /opt/ibm/director/bin/isd-backup.sh backup