d3.ksh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/ksh
  2. function is_guarded
  3. {
  4. return `${ORACLE_HOME}/bin/sqlplus -S / "as sysdba" <<-EOF
  5. set pagesize 0 feedback off verify off heading off termout off echo off
  6. select count(1) from sys.v\\$archive_dest where status = 'VALID' and target = 'STANDBY';
  7. EOF`
  8. }
  9. get_db_role()
  10. {
  11. database_role=`${ORACLE_HOME}/bin/sqlplus -S / "as sysdba" <<-EOF
  12. set pagesize 0 feedback off verify off heading off termout off echo off
  13. select database_role from sys.v\\$database;
  14. EOF`
  15. }
  16. is_guarded
  17. retval=$?
  18. # echo "is_guarded returned ---${retval}---"
  19. get_db_role
  20. echo "${retval}:$database_role"
  21. if [ $retval -eq 0 -a "${database_role}" = "PRIMARY" -o $retval -eq 0 -a "${database_role}" = "PHYSICAL STANDBY" ] ; then
  22. echo -e "1. Not Guarded and Primary ($database_role) - or Not Guarded and Physical Standby - BACKUP HERE"
  23. elif [ $retval -eq 0 -a "${database_role}" = "PHYSICAL STANDBY" ]; then #
  24. echo -e "2. Not Guarded and Physical Standby ($database_role) - BACKUP HERE"
  25. elif [ $retval -gt 0 -a "${database_role}" = "PRIMARY" ]; then #
  26. echo -e "3. Guarded and Primary ($database_role) - NO BACKUP HERE"
  27. else
  28. echo -e "ERROR Unknown Configuration"
  29. fi
  30. #
  31. #
  32. # if [ $retval -gt 0 -a "${database_role}" = "PRIMARY" ]; then
  33. # echo -e "1. Guarded and Primary ($database_role) - NO BACKUP HERE"
  34. # elif [ $retval -eq 0 -a "${database_role}" = "PRIMARY" ]; then # OK: SIT3, UAT3, SYSTST2.......
  35. # echo -e "2. Not Guarded and Primary ($database_role) - BACKUP HERE"
  36. # elif [ $retval -eq 0 -a "${database_role}" = "PHYSICAL STANDBY" ]; then #
  37. # echo -e "3. Not Guarded and Physical Standby ($database_role) - BACKUP HERE"
  38. # else
  39. # echo -e "ERROR Unknown Configuration"
  40. # fi