Shell script to convert physical standby database into snapshot standby and vice versa

 

Today I will show a scenario where a customer had a requirement to refresh their snapshot standby database. The setup was 1 primary database and 2 physical standby databases among which one standby database was always kept in physical standby mode but the other one was used by the developer and a daily refresh was the requirement.

Since they wanted to convert snapshot standby into physical standby for sync and later convert it back to snapshot standby I prepared two shell script to perform the entire activity.

 

·       Shell script to convert physical standby database into snapshot standby database

#!/bin/bash


 # Set environment variables

export ORACLE_HOME=/u01/oracle/19.3.0

export ORACLE_SID=PROD

export PATH=$ORACLE_HOME/bin:$PATH

 

# Define database names

PRIMARY_DB_NAME=PROD

STANDBY_DB_NAME=SBDB

 

# Define log file path

rm $LOG_FILE

LOG_FILE=/u01/snapshot_convert_logfile.log

 

# Define maximum number of retries

MAX_RETRIES=2

 

# Function to log messages to log file

log() {

  echo "$(date +'%Y-%m-%d %H:%M:%S') $1" >> $LOG_FILE

}

 

# Function to perform conversion

perform_conversion() {

  log "Performing conversion of $STANDBY_DB_NAME to snapshot standby..."

  dgmgrl <<EOF

  connect /

  convert database $STANDBY_DB_NAME to snapshot standby;

EOF

} >> $LOG_FILE

# Retry loop

retries=0

while [ $retries -lt $MAX_RETRIES ]; do

  perform_conversion

  if grep -q "ORA-" $LOG_FILE; then

    log "Error occurred during conversion. Retrying..."

    ((retries++))

    sleep 5

  else

    log "Conversion completed successfully. Standby database is now a snapshot standby."

    break

  fi

done

 

# Check for maximum retries

if [ $retries -eq $MAX_RETRIES ]; then

  log "Maximum retries reached. Conversion failed. Please check the log for details."

fi

 

 

·       Shell script to convert snapshot standby database into physical standby database

#!/bin/bash

 

# Set environment variables

export ORACLE_HOME=/u01/oracle/19.3.0

export ORACLE_SID=PROD

export PATH=$ORACLE_HOME/bin:$PATH

 

# Define database names

PRIMARY_DB_NAME=PROD

STANDBY_DB_NAME=SBDB

 

# Define log file path

rm $LOG_FILE

LOG_FILE=/u01/physical_convert_logfile.log

 

# Define maximum number of retries

MAX_RETRIES=2

 

# Function to log messages to log file

log() {

  echo "$(date +'%Y-%m-%d %H:%M:%S') $1" >> $LOG_FILE

}

 

# Function to perform conversion

perform_conversion() {

  log "Performing conversion of $STANDBY_DB_NAME to physical standby..."

dgmgrl sys/Prodpassword@prod<<EOF

convert database $STANDBY_DB_NAME to physical standby;

EOF

} >> $LOG_FILE

# Retry loop

retries=0

while [ $retries -lt $MAX_RETRIES ]; do

  perform_conversion

  if grep -q "ORA-" $LOG_FILE; then

    log "Error occurred during conversion. Retrying..."

    ((retries++))

    sleep 5

  else

    log "Conversion completed successfully. Standby database is now a physical standby."

    break

  fi

done

 

# Check for maximum retries

if [ $retries -eq $MAX_RETRIES ]; then

  log "Maximum retries reached. Conversion failed. Please check the log for details."

fi

 

Once the snapshot standby is converted to physical standby, give it time to synchronize with primary database.

2 comments:

  1. To work better with database, you can use universal data access components.

    ReplyDelete
  2. Hello Everyone !

    If you're in searching of Legit & Fresh Fullz..
    You're at RIGHT PLACE

    Providing Fresh Spammed UPDATED 2023 Fullz with guarantee
    Stuff will be genuine & Legit (replace if found invalid)
    Many Countries Fullz Available
    USA|UK|CANADA|RU|AUS|FR|ASIA

    <-Feel Free To Contact Us & Enjoy->
    ---------------------------------
    ICQ> 752822040 | @killhacks
    Telegram> @killhacks | @leadsupplier
    Skype|WICKR> @peeterhacks
    Email> bigbull0334 @ onion mail . org
    WhatsApp> (On Demand)

    =============
    FULLZ LIST
    =============
    SSN DOB DL ADDRESS FULLZ
    SIN DOB ADDRESS FULLZ (CANADA)
    CC FULLZ WITH CVV & BILLING ADDRESS
    HIGH CREDIT SCORES PROS (700+ Credit)
    DL/ID SCAN FRONT & BACK WITH SELFIE & SSN (ALL USA STATES)
    BUSINESS EIN COMPANY FULLZ
    SPECIFIC FULLZ (GENDER|CITY|STATE|AGE)
    BULK FULLZ (USA|CANADA|UK)
    PUA|UI|KYC|TAX RETURN FILLING FULLZ
    CLONING DUMPS CARD WITH PIN (TRACK 101&202)
    YOUNG AGE FULLZ (2002 ABOVE)
    FULLZ WITH CURRENT EMPLOYEE & BANK DETAILS

    (USA)
    Name + SSN + Dob + DL|ID Number + Address + Phone + Email + Work Info + Bank Info
    claudia|gonzalez|567850156|10.04.1985|d3150237|335Dorisave|OXNARD|CA|93030|8056519095|8056519095|littleone0704@yahoo.com|cabrilloradiation|8056485133|VENTURACOUNTYCREDIT|144210|322283505

    (CANADA)
    NAME + ADDRESS + CITY + STATE + COUNTRY + DOB + SIN + PHONE + MMN + ZIPCODE
    KARINE BEAUDOIN|590 RUE PRINCIPALE|ST/THEOPHILE|QUEBEC|CA|1977/06/12|276-116-449|4182227484|LAMBERT|G0M 2A0

    CC Number + Expmm + Expyyyy + CVV + Name + Address + Country + SSN + DOB + Phone
    4610460213146269|07|24|914|Sydney Cutsail|9000 Tate Avenue|76244|Keller|Texas|United States|636-52-0685|04/06/1996|9034951145

    Many other stuff available regarding Fullz & Tools
    Payment Mode BTC|USDT|ETH (Preferable) or any Crypto payment accepted
    No sampling for CC's & DL|ID Scans
    Payment Upfront
    Stuff will be provided within few mins after payment proof
    Testing will be for bulk buyers only
    ***********************************************************************

    TOOLS|TUTORIALS|METHODS|CLONING|SCRIPTING|SCAM-PAGES

    All HACKING|SPAMMING|CARDING|SCRIPTING Tools are Available
    Including all tutorials & E-books
    Updated Loan Methods & Carding Methods

    TOOLS LIST
    -SMTP|RDP
    -SHELLS|C-PANELS
    -WEB MAILERS
    -BRUTES
    -MAILERS|SENDERS|BOMBERS
    -CC CHECKER|CC VALIDATOR
    -SMTP LINUX ROOT
    -SCAM PAGES|SCAM PAGE SCRIPTING
    -LOAN|ATM CARD METHODS
    -CLONING TUTORIALS
    -OFFICE365 LEADS|LOGINS|SMTPS

    Valid & Genuine Tools will be provided with guarantee
    Fresh Tools & Tutorials on demand with updates
    Hacking|Spamming|Carding Packages are available too
    No testing for Tools

    Here we're:
    -------------------------------------
    ICQ> 752822040 | @killhacks
    Telegram> @killhacks | @leadsupplier
    Skype|WICKR> @peeterhacks
    Email> bigbull0334 @ onion mail . org
    WhatsApp> (On Demand)

    Just Try Our Stuff
    It will Never Disappoint You Guy's
    Come & Join US to Make A GooD Money

    ReplyDelete