Full Documentation (with Scripts Included)
This document describes the full workflow and scripts used to restore an Oracle database on an alternate server using NetBackup and an RMAN Recovery Catalog.
The end-to-end process consists of:
- Dropping the existing database
- Starting the instance in NOMOUNT mode
- Restoring the control file
- Restoring the database datafiles
- Performing database recovery
- Renaming the database (DBNEWID)
All scripts include logging and are designed for repeatable controlled refresh operations.
Step 1 – Drop the Existing Database
Description
This script removes an existing Oracle database on the target host prior to refresh.
It shuts down the database, mounts it, places it in restricted mode, and executes DROP DATABASE.
Key Notes
- Requires ORACLE_SID as argument
- Uses SQL*Plus to issue shutdown, mount, and drop operations
- Logs all activity to:
drop_database_<SID>.log
Script: drop_database.sh
#!/bin/bash
# Check if the SID parameter is provided
if [ -z "$1" ]; then
echo "Usage: $0 <ORACLE_SID>"
exit 1
fi
# Set Oracle environment variables
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1 # path to your Oracle home
export PATH=$ORACLE_HOME/bin:$PATH
# Define logfile with SID
LOGFILE="/home/oracle/scripts/logs/drop_database_$ORACLE_SID.log" #logfile path
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE"
}
# Drop the database
{
log_message "Starting the process to drop the database: $ORACLE_SID"
sqlplus / as sysdba <<EOF
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
DROP DATABASE;
EOF
log_message "Database with SID $ORACLE_SID dropped successfully."
} >> "$LOGFILE" 2>&1
echo "Check the logfile at $LOGFILE for details."
Step 2 – Start the Database in NOMOUNT Mode
Description
Starts the Oracle instance in NOMOUNT using a custom PFILE.
This is required before restoring the control file.
Key Notes
- Requires ORACLE_SID as argument
- Uses init<SID>.ora located in:
/home/oracle/scripts/automation/pfile/
Script: start_database_nomount.sh
# Check if the SID parameter is provided
if [ -z "$1" ]; then
echo "Usage: $0 <ORACLE_SID>"
exit 1
fi
# Set Oracle environment variables
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1 # Adjust to your Oracle home path
export PATH=$ORACLE_HOME/bin:$PATH
# Define logfile with SID
LOGFILE="/home/oracle/scripts/logs/start_database_$ORACLE_SID_$(date +%Y%m%d_%H%M%S).log" # Logfile path
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE"
}
# Start the database in NOMOUNT mode
{
log_message "Starting the database: $ORACLE_SID in NOMOUNT mode."
sqlplus / as sysdba <<EOF
STARTUP NOMOUNT PFILE='/home/oracle/scripts/automation/pfile/init${ORACLE_SID}.ora';
EOF
if [ $? -eq 0 ]; then
log_message "Database $ORACLE_SID started in NOMOUNT mode successfully."
else
log_message "Error starting database $ORACLE_SID in NOMOUNT mode."
fi
} >> "$LOGFILE" 2>&1
echo "Check the logfile at $LOGFILE for details."
Step 3 – Restore the Control File
Description
Retrieves the latest control file backup for the provided restore date from the RMAN Recovery Catalog.
Then restores it with RMAN using NetBackup SBT channels.
Key Notes
- Requires ORACLE_SID and restore date
- Queries RMAN catalog tables
- Restores controlfile and mounts database
- Uses NetBackup SBT channels with SEND parameters
Script: restore_controlfile.sh
#!/bin/bash
# Check if the required parameters are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <ORACLE_SID> <RESTORE_DATE (DD-MON-YY)>"
exit 1
fi
# Set Oracle environment variables
export ORACLE_SID=$1
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
#Change data format
echo $RESTORE_DATE
# Assign the restore date from the second parameter
# Define logfile with SID and timestamp
LOGFILE="/home/oracle/scripts/logs/restore_controlfile_$ORACLE_SID__$(date +%Y%m%d_%H%M%S).log" #logfile path
# Function to log messages
log_message() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> "$LOGFILE"
}
# Fetch the latest control file name from the database
log_message "Fetching the latest control file handle from the recovery catalog for restore date: $RESTORE_DATE."
CONTROL_FILE_NAME=$(
sqlplus -s rcatowner/xxxxxx@RCAT <<EOF
SET HEADING OFF FEEDBACK OFF VERIFY OFF ECHO OFF
SELECT HANDLE
FROM rcatowner.RC_BACKUP_PIECE
WHERE BS_KEY IN (
SELECT BS_KEY
FROM rcatowner.RC_BACKUP_CONTROLFILE
WHERE TRUNC(COMPLETION_TIME) = TO_DATE('$RESTORE_DATE', 'DD-MON-YY')
)
AND DB_ID = 2455106113
AND HANDLE LIKE '%cntrl%'
AND COMPLETION_TIME = (
SELECT MAX(COMPLETION_TIME)
FROM rcatowner.RC_BACKUP_PIECE
WHERE BS_KEY IN (
SELECT BS_KEY
FROM rcatowner.RC_BACKUP_CONTROLFILE
WHERE TRUNC(COMPLETION_TIME) = TO_DATE('$RESTORE_DATE', 'DD-MON-YY')
)
AND DB_ID = 2655103113
AND HANDLE LIKE '%cntrl%'
);
EXIT;
EOF
)
echo $CONTROL_FILE_NAME
# Validate if CONTROL_FILE_NAME was fetched
if [ -z "$CONTROL_FILE_NAME" ]; then
log_message "Error: Could not fetch the control file handle from the recovery catalog for the date: $RESTORE_DATE."
exit 1
fi
log_message "Using control file handle: $CONTROL_FILE_NAME"
# Run RMAN to restore the control file and mount the database
{
log_message "Starting the control file restoration for SID: $ORACLE_SID using control file: $CONTROL_FILE_NAME."
rman catalog rcatowner/xxxxxx@RCAT target / <<EOF
RUN {
ALLOCATE CHANNEL CH01 TYPE SBT_TAPE;
SEND 'NB_ORA_SERV=nbu-backupsvr, NB_ORA_CLIENT=server-prd';
RESTORE CONTROLFILE FROM '$CONTROL_FILE_NAME';
ALTER DATABASE MOUNT;
}
EOF
} >> "$LOGFILE" 2>&1
# Final log message
log_message "Control file restoration process completed."
echo "Control file restoration process completed. Check the logfile: $LOGFILE"
Step 4 – Restore the Database Datafiles
Description
Restores all datafiles from NetBackup based on the backup TAG and the provided restore timestamp.
Key Notes
- Requires ORACLE_SID and restore timestamp
- Allocates three SBT_TAPE channels
- Uses
SET NEWNAMEto relocate datafiles to +DATA ASM disk group - Uses
UNTIL TIMEto restore files to matching restore window
#!/bin/ksh
# Check if both Oracle SID and date are passed as parameters
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <ORACLE_SID> <DATE>"
echo "Example: $0 ORADEV '09/30/2024 19:00:00'"
exit 1
fi
# Set the Oracle SID and date based on the parameters
export ORACLE_SID=$1
RESTORE_DATE=$2
# Set other environment variables
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
# Define log file
LOGFILE="/home/oracle/scripts/logs/restore_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).log"
TRACEFILE="/home/oracle/scripts/logs/restore_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).trc"
# Start logging
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting RMAN restore for ORACLE_SID=$ORACLE_SID, Restore Date=$RESTORE_DATE" >> $LOG_FILE
# Run RMAN with the provided Oracle SID and date, and log output
rman target / CATALOG rcatowner/xxxxxx@RCAT trace=${TRACEFILE} log=${LOGFILE} <<EOF
set echo on;
debug on;
RUN{
ALLOCATE CHANNEL CH01 TYPE SBT_TAPE;
SEND 'NB_ORA_SERV=nbu-backupsvr, NB_ORA_CLIENT=server-prd';
set newname for DATABASE to '+DATA';
set UNTIL TIME "to_date('$RESTORE_DATE','MM/DD/YYYY HH24:MI:SS')";
restore database FROM TAG 'HOT_DB_BK_INC_LVL0';
}
debug off;
EOF
# Check the exit status of the RMAN command and log it
if [ $? -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] RMAN restore completed successfully." >> $LOG_FILE
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] RMAN restore failed." >> $LOG_FILE
fi
echo "Output logged to $LOG_FILE"
Script: restore_database.sh
#!/bin/ksh
# Check if both Oracle SID and date are passed as parameters
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <ORACLE_SID> <DATE>"
echo "Example: $0 ORADEV '09/30/2024 19:00:00'"
exit 1
fi
# Set the Oracle SID and date based on the parameters
export ORACLE_SID=$1
RESTORE_DATE=$2
# Set other environment variables
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
# Define log file
LOGFILE="/home/oracle/scripts/logs/restore_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).log"
TRACEFILE="/home/oracle/scripts/logs/restore_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).trc"
# Start logging
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting RMAN restore for ORACLE_SID=$ORACLE_SID, Restore Date=$RESTORE_DATE" >> $LOG_FILE
# Run RMAN with the provided Oracle SID and date, and log output
rman target / CATALOG rcatowner/xxxxx@RCAT trace=${TRACEFILE} log=${LOGFILE} <<EOF
set echo on;
debug on;
RUN{
ALLOCATE CHANNEL CH01 TYPE SBT_TAPE;
SEND 'NB_ORA_SERV=nbu-backupsvr, NB_ORA_CLIENT=server-prd';
set newname for DATABASE to '+DATA';
set UNTIL TIME "to_date('$RESTORE_DATE','MM/DD/YYYY HH24:MI:SS')";
restore database FROM TAG 'HOT_DB_BK_INC_LVL0';
}
debug off;
EOF
# Check the exit status of the RMAN command and log it
if [ $? -eq 0 ]; then
echo "[$(date '+%Y-%m-%d %H:%M:%S')] RMAN restore completed successfully." >> $LOG_FILE
else
echo "[$(date '+%Y-%m-%d %H:%M:%S')] RMAN restore failed." >> $LOG_FILE
fi
echo "Output logged to $LOG_FILE"
Step 5 – Recover the Database
Description
Applies archived redo logs to bring the database forward in time and opens it with RESETLOGS.
Key Notes
- Requires ORACLE_SID + recovery timestamp
- Uses up to 6 SBT channels
- Issues:
RESET DATABASE TO INCARNATIONSWITCH DATABASE TO COPYRECOVER DATABASEALTER DATABASE OPEN RESETLOGS
#!/bin/ksh
# Check for required arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <ORACLE_SID> <DATE>"
echo "Example: $0 ORADEV '10/01/2024 08:00:00'"
exit 1
fi
# Accepting command line arguments
export ORACLE_SID="$1"
TARGET_DATE="$2"
# Set Oracle environment
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
# Log file
LOG_FILE="/home/oracle/scripts/logs/recover_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).log"
TRACEFILE="/home/oracle/scripts/logs/recover_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).trc"
{
echo "Starting RMAN operations for ORACLE_SID: $ORACLE_SID on $(date)"
echo "Using target date: $TARGET_DATE"
rman target / trace=${TRACEFILE} log=${LOG_FILE} <<EOF
set echo on;
debug on;
reset database to incarnation 3;
switch database to copy;
RUN {
ALLOCATE CHANNEL CH01 TYPE SBT_TAPE;
SEND 'NB_ORA_SERV=nbu-backupsvr, NB_ORA_CLIENT=server-prd';
SET UNTIL TIME "TO_DATE('$TARGET_DATE', 'MM/DD/YYYY HH24:MI:SS')";
RECOVER DATABASE;
}
alter database open resetlogs;
debug off;
EOF
echo "RMAN recovery completed successfully for ORACLE_SID: $ORACLE_SID."
} &>> "$LOG_FILE"
echo "Output logged to $LOG_FILE"
Step 6 – Rename the Database (DBNEWID)
Description
Renames the database and DBID using Oracle’s DBNEWID (NID) tool.
This is required when cloning a database to avoid DBID conflicts.
Key Notes
- Requires new SID as argument
- Updates ORACLE_SID
- Performs:
- Shutdown
- Start MOUNT
- Execute NID
- Open database RESETLOGS
Script: rename_database.sh
#!/bin/bash
# Function to log messages with timestamp
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOGFILE"
}
# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
log "Usage: $0 <new_sid>"
exit 1
fi
# Get the new SID from the command line argument
NEW_SID="$1"
# Set the old SID (you can modify this based on your requirements)
OLD_SID="old_dbname" # Replace this with your actual old SID
# Ensure the script is run as the Oracle user
if [ "$(whoami)" != "oracle" ]; then
log "This script must be run as the oracle user."
exit 1
fi
# Set environment variables
export ORACLE_SID=$NEW_SID
export ORACLE_HOME=/u01/app/oracle/product/19.26.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
# Define database names
OLD_DBNAME='PROD'
NEW_DBNAME=$NEW_SID
# Database SYS password
SYS_PASSWORD="XXXXXX"
# Path to PFILE
PFILE_PATH="$ORACLE_HOME/dbs/init$OLD_DBNAME.ora"
# Define log file
LOGFILE="/home/oracle/scripts/logs/rename_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).log"
# Start logging
echo "Starting the database rename process..."
echo "New NID name is: $NEW_DBNAME"
# Shutdown the database
echo "Shutting down the database..."
sqlplus sys/$SYS_PASSWORD as sysdba <<EOF >> $LOGFILE
SHUTDOWN IMMEDIATE;
STARTUP MOUNT PFILE='/home/oracle/scripts/automation/pfile/init${ORACLE_SID}.ora';
EXIT;
EOF
# Modify the DB name using NID (DBNEWID utility) with the SYS password
echo "Running NID to rename the database..."
nid target=sys/$SYS_PASSWORD dbname=$NEW_DBNAME logfile=/home/oracle/scripts/logs/nid_${ORACLE_SID}_$(date +%Y%m%d_%H%M%S).log
# If NID fails, exit
if [ $? -ne 0 ]; then
log "NID failed. Check the log file: $LOGFILE"
exit 1
fi
# Update ORACLE_SID
echo "Updating ORACLE_SID..."
export ORACLE_SID=$NEW_DBNAME
# Start the database in MOUNT mode
log "Starting the database in MOUNT mode..."
sqlplus sys/$SYS_PASSWORD as sysdba <<EOF >> $LOGFILE
STARTUP MOUNT;
EXIT;
EOF
# Open the database with RESETLOGS
log "Opening the database with RESETLOGS..."
sqlplus sys/$SYS_PASSWORD as sysdba <<EOF >> $LOGFILE
ALTER DATABASE OPEN RESETLOGS;
EXIT;
EOF
echo "Database rename complete."
exit 0
Complete Workflow Summary
| Step | Script | Description |
|---|---|---|
| 1 | drop_database.sh | Remove existing database entirely |
| 2 | start_database_nomount.sh | Start instance using PFILE without controlfile |
| 3 | restore_controlfile.sh | Query RMAN catalog, restore controlfile, mount DB |
| 4 | restore_database.sh | Restore all datafiles from NetBackup |
| 5 | recover_database.sh | Apply archived logs, roll DB forward, open RESETLOGS |
| 6 | rename_database.sh | Change DBNAME/DBID using NID utility |
Master automation script — master_restore_one_button.sh
#!/bin/bash
#
# master_restore_one_button.sh
#
# Usage:
# ./master_restore_one_button.sh <TARGET_SID> "<RESTORE_TS>"
#
# <TARGET_SID> - ORACLE_SID to restore (e.g. ORADEV24)
# <RESTORE_TS> - Full restore timestamp (MM/DD/YYYY HH24:MI:SS) e.g. "09/30/2024 19:00:00"
# [NEW_SID] - Optional new SID/name to run rename step (NID)
#
# This script orchestrates the following scripts (must be in same dir or referenced path):
# 1) drop_database.sh
# 2) start_database_nomount.sh
# 3) restore_controlfile.sh
# 4) restore_database.sh
# 5) recover_database.sh
# 6) rename_database.sh (optional, only if NEW_SID provided)
#
# Exit codes:
# 0 - success (all requested steps passed)
# >0 - failure, step name reported in output
#
set -o errexit
set -o nounset
set -o pipefail
### --- CONFIGURE BELOW IF NEEDED ---
SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)" # default: assume all scripts are co-located with this master script
LOG_DIR="/home/oracle/scripts/logs"
mkdir -p "$LOG_DIR"
# Paths to step scripts (adjust if your scripts are located elsewhere)
DROP_SCRIPT="${SCRIPTS_DIR}/drop_database.sh"
START_NOMOUNT_SCRIPT="${SCRIPTS_DIR}/start_database_nomount.sh"
RESTORE_CTRL_SCRIPT="${SCRIPTS_DIR}/restore_controlfile.sh"
RESTORE_DB_SCRIPT="${SCRIPTS_DIR}/restore_database.sh"
RECOVER_DB_SCRIPT="${SCRIPTS_DIR}/recover_database.sh"
RENAME_DB_SCRIPT="${SCRIPTS_DIR}/rename_database.sh"
# NetBackup env/settings are assumed to be handled inside your scripts
# -----------------------------------------------------------------
### --- Helper functions ---
timestamp() { date '+%Y-%m-%d %H:%M:%S'; }
log() {
echo "$(timestamp) - $*" | tee -a "$MASTER_LOG"
}
fail() {
echo "$(timestamp) - ERROR - $*" | tee -a "$MASTER_LOG" >&2
exit 1
}
check_executable() {
if [ ! -x "$1" ]; then
fail "Required script not found or not executable: $1"
fi
}
### --- Input validation ---
if [ "$#" -lt 2 ]; then
cat <<EOF
Usage: $0 <TARGET_SID> "<RESTORE_TS>"
Example:
$0 ORADEV "09/30/2024 19:00:00"
Notes:
- RESTORE_TS must be in format: MM/DD/YYYY HH24:MI:SS (quotes required because of space)
- NEW_SID is optional; if supplied, rename step (NID) will be executed at the end.
EOF
exit 1
fi
TARGET_SID="$1"
RESTORE_TS="$2" # "MM/DD/YYYY HH24:MI:SS"
NEW_SID=TARGET_SID
# derive controlfile date (the restore_controlfile.sh expects a date input that is split by '/')
# restore_controlfile.sh has a perl conversion which expects MM/DD/YYYY (it converts to DD-MON-YY)
# so pass the date portion (MM/DD/YYYY)
CONTROLFILE_DATE="$(echo "$RESTORE_TS" | awk '{print $1}')" # yields MM/DD/YYYY
MASTER_LOG="${LOG_DIR}/master_restore_${TARGET_SID}_$(date +%Y%m%d_%H%M%S).log"
echo "Master restore started at $(timestamp)" | tee -a "$MASTER_LOG"
### --- Verify required scripts exist and are executable ---
log "Verifying required step scripts..."
for s in "$DROP_SCRIPT" "$START_NOMOUNT_SCRIPT" "$RESTORE_CTRL_SCRIPT" "$RESTORE_DB_SCRIPT" "$RECOVER_DB_SCRIPT"; do
check_executable "$s"
done
if [ -n "$NEW_SID" ]; then
check_executable "$RENAME_DB_SCRIPT"
fi
log "Script verification completed."
### --- Step 0: Summary / pre-checks ---
log "Parameters:"
log " TARGET_SID = $TARGET_SID"
log " RESTORE_TS = $RESTORE_TS"
log " CONTROL_DATE = $CONTROLFILE_DATE"
if [ -n "$NEW_SID" ]; then
log " NEW_SID = $NEW_SID (rename step will run)"
else
log " NEW_SID = <not provided> (rename step will be skipped)"
fi
# Optional safety: check we're running as 'oracle' user (recommended)
RUN_USER="$(id -un)"
if [ "$RUN_USER" != "oracle" ]; then
log "WARNING: script is running as '$RUN_USER'. Recommended to run as 'oracle' user."
fi
### --- Step 1: Drop existing database (if any) ---
log "STEP 1: Dropping existing database (if present) using $DROP_SCRIPT ..."
if ! "$DROP_SCRIPT" "$TARGET_SID" >> "$MASTER_LOG" 2>&1; then
fail "STEP 1 failed (drop_database). See $MASTER_LOG for details."
fi
log "STEP 1 completed."
### --- Step 2: Start DB in NOMOUNT ---
log "STEP 2: Starting instance in NOMOUNT using $START_NOMOUNT_SCRIPT ..."
if ! "$START_NOMOUNT_SCRIPT" "$TARGET_SID" >> "$MASTER_LOG" 2>&1; then
fail "STEP 2 failed (start_database_nomount). See $MASTER_LOG for details."
fi
log "STEP 2 completed."
### --- Step 3: Restore controlfile from catalog using CONTROLFILE_DATE ---
log "STEP 3: Restoring controlfile using $RESTORE_CTRL_SCRIPT (control date: $CONTROLFILE_DATE) ..."
if ! "$RESTORE_CTRL_SCRIPT" "$TARGET_SID" "$CONTROLFILE_DATE" >> "$MASTER_LOG" 2>&1; then
fail "STEP 3 failed (restore_controlfile). See $MASTER_LOG for details."
fi
log "STEP 3 completed."
### --- Step 4: Restore database datafiles (full restore) ---
log "STEP 4: Restoring database datafiles using $RESTORE_DB_SCRIPT (restore timestamp: $RESTORE_TS) ..."
if ! "$RESTORE_DB_SCRIPT" "$TARGET_SID" "$RESTORE_TS" >> "$MASTER_LOG" 2>&1; then
fail "STEP 4 failed (restore_database). See $MASTER_LOG for details."
fi
log "STEP 4 completed."
### --- Step 5: Recover database to target time and open RESETLOGS ---
log "STEP 5: Recovering database using $RECOVER_DB_SCRIPT (target date: $RESTORE_TS) ..."
if ! "$RECOVER_DB_SCRIPT" "$TARGET_SID" "$RESTORE_TS" >> "$MASTER_LOG" 2>&1; then
fail "STEP 5 failed (recover_database). See $MASTER_LOG for details."
fi
log "STEP 5 completed."
### --- Step 6: Optional rename using NID ---
if [ -n "$NEW_SID" ]; then
log "STEP 6: Renaming database using $RENAME_DB_SCRIPT -> new SID: $NEW_SID"
# WARNING: rename_database.sh currently hardcodes SYS password in the script.
# Recommended: change rename_database.sh to accept a password or use external secret storage.
#
# If your rename script relies on ORACLE_SID environment variable as input, pass accordingly.
#
# We'll call it with NEW_SID as argument.
if ! "$RENAME_DB_SCRIPT" "$NEW_SID" >> "$MASTER_LOG" 2>&1; then
fail "STEP 6 failed (rename_database). See $MASTER_LOG for details."
fi
log "STEP 6 (rename) completed."
else
log "STEP 6: Skipped (no NEW_SID supplied)."
fi
### --- Finalize ---
log "Master restore completed successfully for ORACLE_SID=$TARGET_SID."
log "See logs (master + individual) for details. Master log: $MASTER_LOG"
exit 0
How to use
- Put
master_restore_one_button.shin the same directory as your scripts (or changeSCRIPTS_DIRpath near top). - Make it executable:
chmod +x master_restore_one_button.sh - Run it as the
oracleuser (recommended):./master_restore_one_button.sh ORADEV "09/30/2024 19:00:00"
Operational notes & recommendations (must read)
- Test in non-prod first: Run this workflow in a dev environment to validate NetBackup channel allocations, RMAN catalog connectivity (
RCAT), and ASM+DATApaths. - Backups & snapshot: Keep a pre-restore snapshot or backup of the target server configuration.
- Network & NetBackup: Ensure NetBackup
NB_ORA_SERVandNB_ORA_CLIENTvalues used in scripts are reachable from the target host. - Log retention: Review the log directory retention and rotate older logs.
- Concurrency: Do not run two concurrent master scripts for the same target SID.

