Setting up database backup script on Linux synergy 6.5 server

36 views
Skip to first unread message

TerriR

unread,
Mar 11, 2014, 1:20:43 PM3/11/14
to synergy...@googlegroups.com
This is from our IT person trying to set up a backup script on a synergy 6.5 Linux server (VM):
 

I can run normal commands as ccm_root, such as ccmsrv and ccmdb, but when executed by the backup script they fail to find common executables, e.g. cat, sed, basename, etc. Running the scripts with debugging enabled shows that the PATH variable isn't being passed down to the scripts called by the commands in the backup script.

Here's an example:

We build a list of databases and their states with the 'ccmdb info' command. The first thing it does is call $CCM_HOME/bin/util/ccm_platform. The first executable called by ccm_platform is 'uname,' which it fails to find. When I hard code uname to /bin/uname, the backup script gets past that point.

One thing I noticed is that those secondary scripts don't perform any PATH checking, like they should. I'd hate to have to go through and hard code full paths for every script. Can you see if anyone else has encountered this problem and how they may have fixed it?

Mark Meredith

unread,
Mar 11, 2014, 4:14:16 PM3/11/14
to synergy...@googlegroups.com
Here is the script I use, but it does a ccmdb dump instead of backup, but either should work.
We have to read in the .profile or .bash_profile to get the path environment populated etc. Which I think is what you are missing.
 
 
#!/bin/bash
# directory where backup files go
BkupDir=backups
Unprotect=backups/unprotect.list
# list of databases to backup and number in list.
DatabaseList="db1 db2"
DatabaseCount=9
# number of old backups to save
SaveOldCnt=1
# legato defaults us to root directory
cd /home/ccm_root
case $1 in
   'before')
      # save old log file
      if [ -f $0.log ]; then
        mv $0.log $0.log.old
      fi
      # redirect stdout and stderr to log file
      exec > $0.log
      exec 2>&1
      # legato doesn't read our .profile, so do it here
      . ./.bash_profile
      date
      echo `id`
      # set up location for old backups
      # we use a separate directory so they can be excluded
      # from the backup to tape
      OldBkupDir=$BkupDir/old
      if [ ! -d $OldBkupDir ]; then
        mkdir $OldBkupDir
        if [ $? -ne 0 ]; then
          echo
          echo ERROR: could not create directory $OldBkupDir !!!
          echo
          OldBkupDir=$BkupDir
        fi
      fi
      if [ ! -w $OldBkupDir ]; then
          echo
          echo ERROR: directory $OldBkupDir is not writable !!!
          echo
          OldBkupDir=$BkupDir
      fi
      # move old backup to the directory for old backups
      # (so it doesn't get backed up by tape backup)
      for database in ${DatabaseList}
      do
         if [ $BkupDir != $OldBkupDir ]; then
            mv $BkupDir/${database}_2*.dmp $OldBkupDir
         fi
         # removed old backup files
         i=0;
         ls -t1 $OldBkupDir/${database}_2*.dmp | while read flnm; do
            if [ $i -ge $SaveOldCnt ]; then
               rm $flnm
            fi
            let i=i+1
      done
      done
      for database in ${DatabaseList}
      do
#        if ccmdb shutdown /ccmdb/$database
         if ccmdb protect /ccmdb/$database
         then
            date
            ccmdb dump /ccmdb/${database} -t $BkupDir/${database}.dmp
            # rename current backup to include date in name
            mv -f $BkupDir/${database}.dmp $BkupDir/${database}_`date +%Y.%m.%d_
%H.%M`.dmp;
            date
         else
            echo "Failed shutdown on ${database}"
         fi
      done
      date
      for database in ${DatabaseList}
      do
         ccmdb unprotect /ccmdb/$database
      done
   ;;
   'after')
      exec >> $0.log
      exec 2>&1
      # legato doesn't read our .profile, so do it here
      . ./.bash_profile
      date
      # this is the list that passed the check command, the ones that fail
      # will stay protected. To fix the next morning.
#      for database in `cat $Unprotect`
      for database in ${DatabaseList}
      do
         ccmdb unprotect /ccmdb/$database
      done
#      if [ $DatabaseCount -ne `wc -l <$Unprotect` ]; then
#         echo "Error some Database(s) did not get unprotected!"
#         cat $Unprotect
#         echo "Have been unprotected."
         # email results
#         mailx -s "ERROR `hostname`: $0 results" ccmadmin < $0.log
#      else
         # email results
         mailx -s "`hostname`: $0 results" ccmadmin < $0.log
#      fi
      date
   ;;
    *)
        echo "Usage: dumptest.sh {before|after}"
        ;;
esac
# legato needs this
exit 0


--
You received this message because you are subscribed to the Google Groups "Synergy CM Tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to synergy-cm-to...@googlegroups.com.
To post to this group, send email to synergy...@googlegroups.com.
Visit this group at http://groups.google.com/group/synergy-cm-tool.
For more options, visit https://groups.google.com/d/optout.



--
Mark Meredith
markjm...@gmail.com
" A boat in the harbor is safe
   but that is not what boats are for"
John A. Shed
Reply all
Reply to author
Forward
0 new messages