RMAN backup script failing I have a few linux machines and each of them have a few Oracle databases. On each machine we have 2 shell scripts to run the backups. The TSM scheduler calls a script which calls a different backup script for each DB on the machine.

The problem is if I create an array of SIDs and create a loop through the SIDs the backup fails.

#!/bin/bash

LEVEL="$1"

declare -a SIDS=('SID1' 'SID2' 'SID3')
su - oracle

for SID in ${SIDS[@]}
do
  ORACLE_SID=$SID; export ORACLE_SID
  export ORACLE_HOME='/u01/app/oracle/product/10.2.0.2'
  ORAENV_ASK=NO
  . /usr/local/bin/oraenv
  LD_LIBRARY_PATH=$ORACLE_HOME/lib; export LD_LIBRARY_PATH
  /usr/local/adm/backup-incrn.sh $LEVEL $SID 35
done


There is no error in the Logs on the TSM server and it is almost as if the scripts is never called. The logs that are on the machine are not updated with any error messages.

If I use this syntax the backups work perfectly

su - oracle -c "/usr/local/adm/backup-incrn.sh $LEVEL SID1 35"

su - oracle -c "/usr/local/adm/backup-incrn.sh $LEVEL SID2 35"


I think this has to be an error in my script, some variable not being set properly.

Can anyone see the obvious mistake I've made and point it out to me?

Gísli
I would guess that because you're issuing a login your declaration of SIDS is not transferred to the shell started by the su command.  You can test this by checking the value of SIDS after you issue the "su - oracle"