0% found this document useful (0 votes)
16 views5 pages

RMAN Backup & Restore Guide for ASM

This guide provides instructions for performing full RMAN backups of an Oracle database using ASM storage, transferring backups to another server, and restoring the database. It includes an automated backup shell script, manual backup steps, and common troubleshooting tips. The document outlines the necessary environment setup, backup and restore procedures, and solutions to common issues encountered during the process.

Uploaded by

moizabdul1557
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views5 pages

RMAN Backup & Restore Guide for ASM

This guide provides instructions for performing full RMAN backups of an Oracle database using ASM storage, transferring backups to another server, and restoring the database. It includes an automated backup shell script, manual backup steps, and common troubleshooting tips. The document outlines the necessary environment setup, backup and restore procedures, and solutions to common issues encountered during the process.

Uploaded by

moizabdul1557
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Oracle RMAN Backup & Restore on ASM

1. Introduction
This guide covers performing full RMAN backups of an Oracle database using ASM storage,
transferring backups to another server, and restoring the database there. It includes a
reusable backup shell script, manual backup steps, restore steps, and common
troubleshooting tips.
2. Environment Setup & Assumptions
 Oracle 19c (or newer) installed
 ASM storage for datafiles
 SSH access between source and target servers
 Oracle environment variables (ORACLE_HOME, ORACLE_SID) set properly
 Oracle user with necessary privileges
 Backup directories created on both servers
3. Automated RMAN Backup Script
Create a shell script (e.g., /home/oracle/shell/rman_backup.sh) to automate full backups:
#!/bin/bash
# RMAN FULL BACKUP SCRIPT FOR ASM

export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/db_home
export PATH=$ORACLE_HOME/bin:$PATH

BACKUP_DIR=/u01/backup/backup_rman
LOGFILE="$BACKUP_DIR/rman_backup_$(date +'%Y%m%d_%H%M%S').log"

mkdir -p "$BACKUP_DIR"

echo "Starting RMAN Backup at $(date)" | tee -a "$LOGFILE"

rman target / >> "$LOGFILE" 2>&1 <<EOF


RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK FORMAT '${BACKUP_DIR}/db_%[Link]';
ALLOCATE CHANNEL c2 DEVICE TYPE DISK FORMAT '${BACKUP_DIR}/db_%[Link]';

BACKUP AS COMPRESSED BACKUPSET DATABASE PLUS ARCHIVELOG TAG='FULL_$(date +%Y


%m%d_%H%M)';
BACKUP CURRENT CONTROLFILE FORMAT '${BACKUP_DIR}/ctl_%d_%[Link]';
BACKUP SPFILE TAG='SPFILE_BACKUP';
BACKUP ARCHIVELOG ALL DELETE INPUT TAG='ARCHIVELOG_BACKUP';

RELEASE CHANNEL c1;


RELEASE CHANNEL c2;
}
EOF

if [ $? -eq 0 ]; then
echo "RMAN Backup completed successfully at $(date)" | tee -a "$LOGFILE"
else
echo "RMAN Backup failed at $(date)" | tee -a "$LOGFILE"
fi
Usage
chmod +x /home/oracle/shell/rman_backup.sh
/home/oracle/shell/rman_backup.sh

Now take backup of control file

BACKUP CURRENT CONTROLFILE FORMAT '/u01/backup/backup_rman/ctl_controlfile_%d_


%[Link]';
4. Manual Backup & Transfer Steps
After running the script:
1. Create PFILE from SPFILE:
sqlplus / as sysdba
SQL> create pfile='/tmp/[Link]' from spfile;

2. Create password file:


orapwd file=$ORACLE_HOME/dbs/orapwORCL password=YourStrongPassword entries=10
force=y

3. Transfer backups & files to the target server:


scp -r /u01/backup/backup_rman oracle@<target_ip>:/u01/backup/
scp /tmp/[Link] oracle@<target_ip>:/tmp/
scp $ORACLE_HOME/dbs/orapwORCL oracle@<target_ip>:$ORACLE_HOME/dbs/

Also send control file

5. Restore Procedure on Target Server


5.1 Startup and Restore Controlfile
sqlplus / as sysdba
SQL> startup nomount pfile='/tmp/[Link]';
rman target /
RMAN> restore controlfile from '/u01/backup/backup_rman/ctl_<db>_<date>.bkp';
RMAN> alter database mount;

5.2 Restore and Recover Database


RUN {
ALLOCATE CHANNEL c1 DEVICE TYPE DISK;
ALLOCATE CHANNEL c2 DEVICE TYPE DISK;

SET NEWNAME FOR DATABASE TO '+DATA';


RESTORE DATABASE;
SWITCH DATAFILE ALL;
RECOVER DATABASE;

RELEASE CHANNEL c1;


RELEASE CHANNEL c2;
}

5.3 Open Database


If archive logs are missing and recovery cannot complete:
ALTER DATABASE OPEN RESETLOGS;
6. Common Issues & Tips

Problem Solution

VALIDATE BACKUPSET ALL Use VALIDATE BACKUPSET <backupset_number>; ALL is not


error accepted.

Open DB with ALTER DATABASE OPEN RESETLOGS; after


Archive log missing errors
recovery.

Confirm Oracle user has read/write permissions on backup


Permission errors
directories.

Create with orapwd and copy to correct $ORACLE_HOME/dbs


Password file not found
path.

You might also like