1 2 Previous Next 17 Replies Latest reply: Mar 12, 2012 11:55 AM by 875513 RSS

    scheduled backup not happening, but manually does!!!!!!!

    875513
      Hi guys,

      Good day

      I am having a hard time in the final steps of configuring Oracle cold Backup.we have Oracle 8i running on SunSolaris 5.8. we have written a script to take the cold backup. when we run it manually it works fine and we were able to restore the backup in target server. But when we scheduled with cron tabs, the backup is not happening(script is running fine i.e listener stops, database shutting down etc).. the plan is to take the backup to the tapes using "ufsdump" from that restore it on target server. script as follows


      #!/bin/bash
      # for database backup
      #
      ORACLE_HOME=/oracle/oracle8i ; export ORACLE_HOME

      dt1=`date | cut -d" " -f1`
      echo $dt1

      #echo "Backup Process started on .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      echo "Backup Process started on .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      echo "Tape rewinding is started .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      mt -f /dev/rmt/0n rew

      echo "Tape rewinding is completed .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      echo "Database Shutdown in progress ." | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

           if [ -f /oracle/oracle8i/bin/svrmgrl ]; then
      /oracle/oracle8i/bin/lsnrctl stop >> /oracle/oracle8i/anil/bkup_${dt1}.log

      sleep 300

           /oracle/oracle8i/bin/dbshut >> /oracle/oracle8i/anil/bkup_${dt1}.log
      fi

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      ps -aef | grep ora_pmon | grep -v grep >> /oracle/oracle8i/anil/bkup_${dt1}.log

      ps -aef | grep ora_ | grep -v grep > /oracle/oracle8i/anil/dbstatus_1.log

      ps -aef | grep ora_pmon | grep -v grep > /oracle/oracle8i/anil/dbstatus.log

      if [ -s /oracle/oracle8i/anil/dbstatus.log ]
      then
      flag=0
      echo flag is $flag database running | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      else
      flag=1
      echo flag is $flag database down | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      fi


      if [ $flag -eq 1 ]
      then

      echo "flag is ${flag} Backup process started .." | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      sleep 120

      ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/anil/bkup_${dt1}.log*
      ufsdump 0uf /dev/rmt/0bn /data1/oradata >> /oracle/oracle8i/anil/bkup_${dt1}.log*
      ufsdump 0uf /dev/rmt/0bn /data2/oradata >> /oracle/oracle8i/anil/bkup_${dt1}.log*


      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      cp -p /data1/oradata/control*.ctl /data1/bkup_cntrl_redo/
      cp -p /data1/oradata/redo*.log /data1/bkup_cntrl_redo/

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      echo " Database is comming up .." | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

           if [ -f /oracle/oracle8i/bin/svrmgrl ]; then
           /oracle/oracle8i/bin/dbstart >> /oracle/oracle8i/anil/bkup_${dt1}.log
      /oracle/oracle8i/bin/lsnrctl start >> /oracle/oracle8i/anil/bkup_${dt1}.log
      fi

      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      echo "Tape rewinding is started .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      mt -f /dev/rmt/0n rew

      echo "Tape rewinding is completed .." > /oracle/oracle8i/anil/bkup_${dt1}.log

      echo "Data reading from the DAT .." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      sleep 120

           

      mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 >> /oracle/oracle8i/anil/bkup_${dt1}.log*
      mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 >> /oracle/oracle8i/anil/bkup_${dt1}.log*
      mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 >> /oracle/oracle8i/anil/bkup_${dt1}.log*

      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log
      echo ".." |tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      date | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      echo " Backup Process is over ....." | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      find /data1/arch/ -name "arch*.arc" -mtime +40 -exec rm {} \;

      else

      echo " Backup not taken ... " | tee -a /oracle/oracle8i/anil/bkup_${dt1}.log

      fi


      cp -p /oracle/oracle8i/anil/bkup*.log /backup/guest/bkup_status/

      In the above script everything is happening other than taking backup when we run it using crontabs..

      if we run this script manually it works awesome..

      Can you help me please.
        • 1. Re: scheduled backup not happening, but manually does!!!!!!!
          clcarter
          everything is happening other than taking backup
          Which line(s) are the "taking backup" part? Is it the `ufsdump ...` command(s)?

          Check the file where the command output is going, is there perhaps a "bash: ufsdump: command not found" in the log? Might need some path adjustments in the script, a job run from cron will not have all the same environment settings as a login session does.

          And why the splats on those file names ...
           ... >> /oracle/oracle8i/anil/bkup_${dt1}.log*
          May not be getting what you want, but what the .sh script is asking for looks a bit odd.
          • 2. Re: scheduled backup not happening, but manually does!!!!!!!
            sb92075
            #!/bin/bash
            # for database backup
            #
            ORACLE_HOME=/oracle/oracle8i ; export ORACLE_HOME
            env | sort -o /tmp/capture.log

            modify script to add new line as above.
            reschedule via cron
            post content of /tmp/capture.log back here
            • 3. Re: scheduled backup not happening, but manually does!!!!!!!
              LKBrwn_DBA
              And perhaps also set the ORACLE_SID?
              #!/bin/bash
              # for database backup
              #
              ORACLE_HOME=/oracle/oracle8i 
              ORACLE_SID=orcl
              PATH=$ORACLE_HOME/bin:$PATH
              export ORACLE_HOME ORACLE_SID PATH
              # ... Etc ...
              • 4. Re: scheduled backup not happening, but manually does!!!!!!!
                875513
                Thanks for your reply,

                The lines we are using to take the backup are

                ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/anil/bkup_${dt1}.log*
                ufsdump 0uf /dev/rmt/0bn /data1/oradata >> /oracle/oracle8i/anil/bkup_${dt1}.log*
                ufsdump 0uf /dev/rmt/0bn /data2/oradata >> /oracle/oracle8i/anil/bkup_${dt1}.log*

                and the log file as follows

                Backup Process started on ..
                Wed Mar 7 02:00:01 GMT 2012
                Tape rewinding is started ..
                Tape rewinding is completed..
                Database Shutdown in progress .
                Wed Mar 7 02:00:21 GMT 2012

                LSNRCTL for Solaris: Version 8.1.6.0.0 - Production on 07-MAR-2012 02:00:21

                (c) Copyright 1998, 1999, Oracle Corporation. All rights reserved.

                Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
                The command completed successfully

                Oracle Server Manager Release 3.1.6.0.0 - Production

                Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.

                Oracle8i Enterprise Edition Release 8.1.6.1.0 - 64bit Production
                With the Partitioning option
                JServer Release 8.1.6.1.0 - 64bit Production

                SVRMGR> Connected.
                SVRMGR> Database closed.
                Database dismounted.
                ORACLE instance shut down.
                SVRMGR>
                Server Manager complete.
                Database "T0000" shut down.
                Wed Mar 7 02:06:53 GMT 2012
                flag is 1 database down
                flag is 1 Backup process started ..
                ..
                ..
                Wed Mar 7 02:08:53 GMT 2012
                Wed Mar 7 02:10:14 GMT 2012
                Database is comming up ..

                SQL*Plus: Release 8.1.6.0.0 - Production on Wed Mar 7 02:10:15 2012

                (c) Copyright 1999 Oracle Corporation. All rights reserved.

                SQL> Connected to an idle instance.
                SQL> ORACLE instance started.

                Total System Global Area 2433879972 bytes
                Fixed Size          94116 bytes
                Variable Size          791699456 bytes
                Database Buffers     1610612736 bytes
                Redo Buffers          31473664 bytes
                Database mounted.
                Database opened.
                SQL> Disconnected

                Database "T0000" warm started.

                LSNRCTL for Solaris: Version 8.1.6.0.0 - Production on 07-MAR-2012 02:10:49

                (c) Copyright 1998, 1999, Oracle Corporation. All rights reserved.

                Starting /oracle/oracle8i/bin/tnslsnr: please wait...

                TNSLSNR for Solaris: Version 8.1.6.0.0 - Production
                System parameter file is /oracle/oracle8i/network/admin/listener.ora
                Log messages written to /oracle/oracle8i/network/log/listener.log
                Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC)))
                Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.17.1.2)(PORT=1521)))
                Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.17.1.2)(PORT=2481))(PROTOCOL_STACK=(PRESENTATION=GIOP)(SESSION=RAW)))

                Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
                STATUS of the LISTENER
                ------------------------
                Alias LISTENER
                Version TNSLSNR for Solaris: Version 8.1.6.0.0 - Production
                Start Date 07-MAR-2012 02:10:50
                Uptime 0 days 0 hr. 0 min. 0 sec
                Trace Level off
                Security OFF
                SNMP OFF
                Listener Parameter File /oracle/oracle8i/network/admin/listener.ora
                Listener Log File /oracle/oracle8i/network/log/listener.log
                Services Summary...
                PLSExtProc          has 1 service handler(s)
                T0000          has 1 service handler(s)
                The command completed successfully
                ..
                Wed Mar 7 02:10:50 GMT 2012
                Tape rewinding is started..
                Tape rewinding is completed..
                Data reading from the DAT ..
                ..
                ..
                ..
                Wed Mar 7 02:14:11 GMT 2012
                Backup Process is over .....
                • 5. Re: scheduled backup not happening, but manually does!!!!!!!
                  819493
                  Hi,

                  Do you capture stderr anywhere? If you don't, you can do it either in cron, with
                  00 00 * * * backupscript.sh 2>&1 >> cronout.log
                  or in the script, by adding
                  ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1 
                  Also, I've seen differences in the environment in a interactive shell and in cron, so a good idea is to use the absolute path to ufsdump in the script. (Personally, I do it always on all executables, so I can control which one's being used)

                  HtH
                  Johan
                  • 6. Re: scheduled backup not happening, but manually does!!!!!!!
                    875513
                    Hi Johan,

                    As u said I have made the changes to he script i.e

                    ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1
                    ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/data1 >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1
                    ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/data2 >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1


                    the stderr shows "command not found" for thee lines....

                    I think there might be some syntax issues.

                    Can u please assist me!
                    • 7. Re: scheduled backup not happening, but manually does!!!!!!!
                      sb92075
                      Naveen Kumar wrote:
                      Hi Johan,

                      As u said I have made the changes to he script i.e

                      ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1
                      ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/data1 >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1
                      ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/data2 >> /oracle/oracle8i/anil/bkup_${dt1}.log 2>&1


                      the stderr shows "command not found" for thee lines....

                      I think there might be some syntax issues.

                      Can u please assist me!
                      it means that ufsdump is not found within PATH

                      post results from two OS commands below

                      echo $PATH
                      find / -name ufsdump -print 2>/dev/null
                      • 8. Re: scheduled backup not happening, but manually does!!!!!!!
                        819493
                        Hi,

                        You can also do
                        which ufsdump
                        and replace 'ufsdump' in the script with the output (probably something like /usr/bin/ufsdump or along those lines).
                        Or do
                        echo $PATH
                        and insert the output from that in the header of your script,
                        i.e.
                        #!/bin/bash
                        export PATH=/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/oracle/11.1/client64/bin:/usr/lib/oracle/11.1/client64/bin
                        HtH
                        Johan
                        • 9. Re: scheduled backup not happening, but manually does!!!!!!!
                          875513
                          Hi

                          The results are

                          echo $PATH
                          usr/sbin:/usr/bin

                          find / -name ufsdump -print 2>/dev/null
                          usr/lib/fs/ufs/ufsdump
                          usr/sbin/ufsdump
                          • 10. Re: scheduled backup not happening, but manually does!!!!!!!
                            Hans Forbrich
                            Naveen Kumar wrote:
                            Hi

                            The results are

                            echo $PATH
                            usr/sbin:/usr/bin

                            find / -name ufsdump -print 2>/dev/null
                            usr/lib/fs/ufs/ufsdump
                            usr/sbin/ufsdump
                            You know that cron will not run any user profile, and therefore will not have the typical login environment (such as PATH), don't you?

                            As others have suggested, put in the absolute path to ufsdump (change all occurances of ufsdump to /usr/sbin/ufsdump) and try again.
                            • 11. Re: scheduled backup not happening, but manually does!!!!!!!
                              875513
                              Hi

                              Sorry am not aware of that..

                              I made the changes to the script

                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/nandu/bkup_${dt1}.log 2>&1
                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /data1/oradata >> /oracle/oracle8i/nandu/bkup_${dt1}.log 2>&1
                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /data2/oradata >> /oracle/oracle8i/nandu/bkup_${dt1}.log 2>&1

                              but the results I got

                              DUMP: Cannot open dump device `/dev/rdsk/c0t0d0s5': Permission denied
                              DUMP: Cannot open dump device `/dev/rdsk/c2t0d0s0': Permission denied
                              DUMP: Cannot open dump device `/dev/rdsk/c2t0d0s1': Permission denied

                              here is the full script

                              ORACLE_HOME=/oracle/oracle8i ; export ORACLE_HOME
                              ORACLE_SID=T0000 ; export ORACLE_SID
                              dt1=`date | cut -d" " -f1`
                              echo $dt1

                              echo "Backup Process started on .." > /oracle/oracle8i/nandu/bkup_${dt1}.log

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo "Tape rewinding is started .." >> /oracle/oracle8i/nandu/bkup_${dt1}.log

                              mt -f /dev/rmt/0n rew

                              echo "Tape rewinding is completed.." >> /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo "Database Shutdown in progress ." | tee -a /oracle/oracle8i/nandu/bkup_${dt
                              1}.log

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              if [ -f /oracle/oracle8i/bin/svrmgrl ]; then
                              /oracle/oracle8i/bin/lsnrctl stop >> /oracle/oracle8i/nandu/bkup_${dt1}.log

                              sleep 300

                              /oracle/oracle8i/bin/dbshut >> /oracle/oracle8i/nandu/bkup_${dt1}.log
                              fi

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              ps -aef | grep ora_pmon | grep -v grep >> /oracle/oracle8i/nandu/bkup_${dt1}.log
                              ps -aef | grep ora_ | grep -v grep > /oracle/oracle8i/nandu/dbstatus_1.log

                              ps -aef | grep ora_pmon | grep -v grep > /oracle/oracle8i/nandu/dbstatus.log

                              if [ -s /oracle/oracle8i/nandu/dbstatus.log ]
                              then
                              flag=0
                              echo flag is $flag database running | tee -a /oracle/oracle8i/nandu/bkup_${d
                              t1}.log
                              else
                              flag=1
                              echo flag is $flag database down | tee -a /oracle/oracle8i/nandu/bkup_${dt1}
                              .log
                              fi


                              if [ $flag -eq 1 ]
                              then

                              echo "flag is ${flag} Backup process started .." | tee -a /oracle/oracle8i/nandu
                              /bkup_${dt1}.log

                              sleep 120

                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /oracle/oracle8i/dbs >> /oracle/oracle8i/nan
                              du/bkup_${dt1}.log 2>&1
                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /data1/oradata >> /oracle/oracle8i/nandu/bkup
                              _${dt1}.log 2>&1
                              /usr/sbin/ufsdump 0uf /dev/rmt/0bn /data2/oradata >> /oracle/oracle8i/nandu/bkup
                              _${dt1}.log 2>&1

                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log
                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              cp -p /data1/oradata/control*.ctl /data1/bkup_cntrl_redo/
                              cp -p /data1/oradata/redo*.log /data1/bkup_cntrl_redo/

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo " Database is comming up .." | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.lo
                              g

                              if [ -f /oracle/oracle8i/bin/svrmgrl ]; then
                              /oracle/oracle8i/bin/dbstart >> /oracle/oracle8i/nandu/bkup_${dt1}.log
                              /oracle/oracle8i/bin/lsnrctl start >> /oracle/oracle8i/nandu/bkup_${dt1}.log
                              fi

                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log
                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo "Tape rewinding is started.." >> /oracle/oracle8i/nandu/bkup_${dt1}.log

                              mt -f /dev/rmt/0n rew

                              echo "Tape rewinding is completed.." >> /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo "Data reading from the DAT .." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.l
                              og
                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              sleep 120



                              mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 1 >> /oracle/oracle8i/nandu/bku
                              p_${dt1}.log
                              mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 2 >> /oracle/oracle8i/nandu/bku
                              p_${dt1}.log
                              mt -f /dev/rmt/0n rew;ufsrestore tfs /dev/rmt/0n 3 >> /oracle/oracle8i/nandu/bku
                              p_${dt1}.log


                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log
                              echo ".." |tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              date | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              echo " Backup Process is over ....." | tee -a /oracle/oracle8i/nandu/bkup_${dt1}
                              .log

                              find /data1/arch/ -name "arch*.arc" -mtime +40 -exec rm {} \;

                              else

                              echo " Backup not taken ... " | tee -a /oracle/oracle8i/nandu/bkup_${dt1}.log

                              fi


                              Thanks
                              Naveen
                              • 12. Re: scheduled backup not happening, but manually does!!!!!!!
                                819493
                                Hi,
                                Naveen Kumar wrote:
                                DUMP: Cannot open dump device `/dev/rdsk/c0t0d0s5': Permission denied
                                DUMP: Cannot open dump device `/dev/rdsk/c2t0d0s0': Permission denied
                                DUMP: Cannot open dump device `/dev/rdsk/c2t0d0s1': Permission denied
                                You say that you can do the backup manually, from the command prompt, but as which user are you running the script then? And as which user is the script running, i.e. from which crontab are you starting the script?

                                Most probably are you (when running the script manually) in a group that the cron-user isn't.
                                Now, it's all down to permissions...

                                You could get a hint on which rights and what groups you need to add the cron-user to, by doing
                                ls -lart /dev/rdsk/c0t0d0s5
                                HtH
                                Johan
                                • 13. Re: scheduled backup not happening, but manually does!!!!!!!
                                  875513
                                  Hi Johan,

                                  As u said the problem here is with the permissions....
                                  while running manually am connecting to oracle user, stopping the listener and shutdown the database. than I am connecting to the root user and running the shell script. so there is no problem with the permissions here!!

                                  When it comes to the cron

                                  Am scheduling the job through oracle's cron (i.e /var/spool/cron/crontabs/oracle) because we can not stop the listener and database from the root user.

                                  so here I need to change the permissions of oracle user on devices..

                                  correct me If am wrong!!!

                                  Thanks,
                                  Naveen.
                                  • 14. Re: scheduled backup not happening, but manually does!!!!!!!
                                    819493
                                    Hi,

                                    Either you change the rights on the disk devices so that the oracle user can read and write to them (and I'm not entirely sure on what needs to be done then, not good enough on Solaris 8), or you make the shutdown/startup-parts run as the oracle-user, and the rest of the script as root.

                                    You can do that by changing
                                    /oracle/oracle8i/bin/lsnrctl stop
                                    to
                                    su - oracle -c "/oracle/oracle8i/bin/lsnrctl stop"
                                    (or at least that works under other *nix:es)

                                    HtH
                                    Johan
                                    1 2 Previous Next