Backup Oracle Databases Using RMAN

Backup and recovery is one of the central themes in the Oracle Database. we talked about user-managed backup and recovery in Oracle, and now we will move on to what is termed server-managed backups, which are managed by RMAN.

RMAN is a tool designed to back up and restore Oracle databases easily. RMAN is like SQL*Plus in some ways

First, RMAN is a client. It connects to the Oracle Database and issues a few commands to the server, and the server actually does the work (hence the term server-based backups).

The following are just a few of the exciting RMAN features:
-It’s free with the Oracle license.
-You can perform full and incremental backups of the entire database, specific tablespaces, and data files.

-You can also back up control files and archive logs.
-RMAN offers persistent parameter configuration for easy backup and recovery.
-RMAN offers automated backups of control files and spfiles.
-You can validate your database backups without actually recovering your database.

-RMAN offers compression of backup images through various means.
-RMAN offers encryption of database backups.
-RMAN provides various backup reporting capabilities.
-RMAN provides scripting capabilities when you are using a recovery catalog.

Configuring RMAN

The Fast Recovery Area(FRA) is the principal store for all Oracle Database backup and recovery

-Backup Set Pieces Files related to RMAN backups
-Archive Log Backups Files related to backups of online redo logs
-Database Archive Logs Archived redo logs that are not backed-up archived redo logs
-Control-File Autobackups Backups of the control file made by RMAN
-Image Copies Backup of data files made by RMAN that are exact copies of the data files of the database
-Database Online Redo Logs Online redo logs of the Oracle Database
-Database Control Files Control files of the Oracle Database
-Flashback Logs Flashback logs of the database

Use the ALTER SYSTEM command to set the parameter DB_RECOVERY_FILE_DEST to c:\oracle01\fra directory and DB_RECOVERY_FILE_DEST_SIZE to 2GB.

Practice:

sql>alter system set db_recovery_file_dest_size=2GB scope=both;
sql>alter system set db_recovery_file_dest='c:\oracle01\fra' scope=spfile;

--Shut down and restart the database. Once the database has been restarted, the FRA will become operational.

SQL> shutdown immediate
SQL> startup 

Starting the RMAN Interface

RMAN is a command-line tool, so you would want to open a command-line window for your operating system.

C:\>set oracle_sid=orcl
C:\>rman target=/

Sometimes you may need to connect to your target database using Oracle Net connection strings.

C:\>rman target=sys/password@orcl

The RMAN Command Prompt

RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACK
UP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; #default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUP SET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 100 M;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR
LOAD TRUE ; # defaultCONFIGURE RMAN OUTPUT TO KEEP FOR 7 DAYS; # default]

You can also look at an individual setting by using the SHOW command

RMAN> show retention policy;

RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

You can clear configuration settings and reset them to the defaults by using the CONFIGURE CLEAR command

RMAN>configure device type disk clear;

Configure control-file autobackups on

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

Configure for compressed backup sets:

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP
TYPE TO COMPRESSED BACKUP SET;

Backing Up Your Database with RMAN

RMAN Image Copies

RMAN> Backup as copy database;

--You can also make image copies of data files or tablespaces
RMAN>backup as copy datafile 4;
RMAN>Backup as copy tablespace users;

This will create a compressed backup of the database, backing up the archived redo logs and then
deleting those backed-up archived redo logs after the backup is complete

RMAN> backup as compressed Backup Set database plus archivelog delete input;

RMAN Backup of Archived Redo Logs

Here is an example of backing up all archived redo logs, still on disk, that were generated in the last 24 hours:

RMAN> backup archivelog time between "sysdate-1" and "sysdate";

Leave a Comment

Your email address will not be published. Required fields are marked *