d2.ksh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. get_db_role
  17. if [ is_guarded -gt 0 -a "${database_role}" = "PRIMARY" ]; then
  18. echo -e "1. Guarded and Primary ($database_role) - NO BACKUP HERE"
  19. elif [ is_guarded -gt 0 -a "${database_role}" = "PHYSICAL STANDBY" ]; then
  20. echo -e "2. Not Guarded and Primary ($database_role) - BACKUP HERE"
  21. elif [ is_guarded -eq 0 -a "${database_role}" = "PRIMARY" ]; then # OK: SIT3, UAT3, SYSTST2.......
  22. echo -e "3. Not Guarded and Primary ($database_role) - BACKUP HERE"
  23. else
  24. echo -e "ERROR Unknown Configuration"
  25. fi
  26. # value=`function "fnordness"`