dd.ksh.backup 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 ]; then
  22. echo -e "BACKUP HERE"
  23. else
  24. echo -e "No Backup here......."
  25. fi
  26. #if [ $retval -eq 0 -a "${database_role}" = "PRIMARY" ]; then
  27. # echo -e "1. Not Guarded and Primary ($database_role) - BACKUP HERE"
  28. #elif [ $retval -eq 0 -a "${database_role}" = "PHYSICAL STANDBY" ] ; then
  29. # echo -e "2. Not Guarded and Physical Standby ($database_role) - BACKUP HERE"
  30. #else
  31. # echo -e "No Backup here......."
  32. #fi
  33. #
  34. #
  35. # if [ $retval -eq 0 -a "${database_role}" = "PRIMARY" ]; then
  36. # echo -e "1. Not Guarded and Primary ($database_role) - BACKUP HERE"
  37. # elif [ $retval -eq 0 -a "${database_role}" = "PHYSICAL STANDBY" ] ; then
  38. # echo -e "2. Not Guarded and Physical Standby ($database_role) - BACKUP HERE"
  39. # elif [ $retval -gt 0 -a "${database_role}" = "PHYSICAL STANDBY" ]; then #
  40. # echo -e "3. Not Guarded and Physical Standby ($database_role) - BACKUP HERE"
  41. # elif [ $retval -gt 0 -a "${database_role}" = "PRIMARY" ]; then #
  42. # echo -e "4. Guarded and Primary ($database_role) - NO BACKUP HERE"
  43. # else
  44. # echo -e "ERROR Unknown Configuration"
  45. # fi
  46. #
  47. #