I apologize in advance if someone has answered this question before, but I am not sure even what to search for here. I have this script for backing up DB2 databases and it works fantastically if there is only on database in the config. My problem is that I have a business intelligence server that has multiple DB's in the directory and the script just falls over. This is the code that performs the work:
My question is, how do I get this to do each DB in turn when going through the backup command.
I believe something like for
But it appears it is not this simple. :wall:
Any help will be appreciated.
Code:
while read inst ; do
db=`su - $inst "-c db2 list db directory" | grep -p Indirect | grep -v HA | sed -n 's!Database alias *= \([A-Z]*\)!\1!p'`
role=`su - $inst "-c db2 get db cfg for $db" | sed -n 's!.*= \(STANDBY\)!\1!p;s!.*= \(PRIMARY\)!\1!p;s!.*= \(STANDARD\)!\1!p;s!^\(SQL30082N\).*!REMOTE!p'`
if [ "$role" == STANDARD ] || [ "$role" == PRIMARY ] ; then
su - $inst "-c db2 backup database $db online use tsm" >> $result
I believe something like for
Code:
i in $db; do su - $inst "-c db2 backup database $i online use tsm" >> $result
Any help will be appreciated.
Moderator's Comments: | ||
|