0

I am trying to run a backup script to backup database Sample

 su -c "${DB2Home}/db2 quiesce database immediate force connections" ${InstanceName} 

    echo "[INFO:`date`]Executing the backup command: ${DB2Home}/db2 backup database ${Primary_Server_DBName} to ${BackupFolder} compress without prompting "

   su -c "${DB2Home}/db2 backup database ${Primary_Server_DBName} to ${BackupFolder} compress without prompting" ${InstanceName}

I executed the script as a root user not as db2inst1 user

I am getting the following error

    [INFO:Tue Oct 21 18:44:23 IST 2014]Executing the backup command: /opt/ibm/db2/V10.5/bin/db2 backup database TIPDB to /home/db2inst1/backupFolder compress without prompting 
  DB21019E  An error occurred while accessing the directory 
    "/root".
user_D_A__
  • 460
  • 2
  • 6
  • 14

2 Answers2

2

The solution is to add . /home/db2inst1/sqllib/db2profile

before the db2 operations

user_D_A__
  • 460
  • 2
  • 6
  • 14
  • Why would you run multiple `su` commands, as opposed to just putting all of the necessary commands in a shell script and executing that shell script via `su` ? – Ian Bjorhovde Oct 21 '14 at 16:25
  • This is just an example. I have only two commands. I dont require a script for it. – user_D_A__ Oct 21 '14 at 17:31
-1

Before running the script use:

su - db2inst1

then run the script as usual:

db2 -stvf /yourpath/createDatabase1.sql
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61