You are on page 1of 10

Step 1: Creating Catalog Database

The catalog database is usually a small database it contains and maintains the
metadata of all rman backups performed using the catalog.

Use DBCA to create Database

Step 2: Create additional tablespaces:

create tablespace catalog datafile '/ora_home/oradata/catdb/catalog01.dbf'


size 250m autoextend on;

Step 3: Create RMAN user

create the rman user that will be the owner of the rman catalog, on the catalog
database.

create user rman identified by rman default tablespace catalog quota


unlimited on catalog;

grant connect, resource, recovery_catalog_owner to rman;

Step 4: Configure Listener.ora / tnsnames.ora

Step 5: create catalog


Connects to the catalog database using the rman command line interface, and creates
the rman catalog. The rman catalog is a set of database objects that will be used
to store the rman backups metadata.

$ rman
Recovery Manager: Release 10.2.0.4.0 - Production on Tue Sep 8 11:16:57 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.

RMAN> connect catalog rman/rman@catdb


connected to recovery catalog database

RMAN> CREATE CATALOG;


RMAN> exit
Recovery Manager complete.

Step 6: Registering database

The databases to be backed up need to be registered.


In this case we execute rman connecting to the database to be registered, the
TARGET and to the CATALOG database.

$ rman target sys/password@db1 catalog rman/rman@catdb


Recovery Manager: Release 10.2.0.4.0 - Production on Tue Sep 8 11:19:26 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: DB1 (DBID=1312345947)
connected to recovery catalog database

RMAN> register database;


database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> show all;

Step 7: Verify-Registration

Once a databases is registered with rman, we can get information about it from the
catalog.
In this case we execute the report schema command to get information.

RMAN> REPORT SCHEMA;

===================================================================================
=================================================================================

Manual-backup-registration

Manual backups, made using Rman without a recovery catalog or user scripts, can be
cataloged and made available to the rman catalog.

eg. CATALOG backuppiece '<filename>'


RMAN> CATALOG backuppiece
'/oradisk/oracle/app/product/11.1.0/db_1/dbs/REDPANDA_c-3603176431-20080531-00';

Create-scripts

Rman tasks can be run using scripts, that can be stored on the rman catalog. Global
scripts will be available to all databases, non-global scripts will be available
only to the target database. This example shows how to create a global script.

CREATE GLOBAL SCRIPT global_full_backup COMMENT 'use only with ARCHIVELOG


mode databases'

{
BACKUP DATABASE PLUS ARCHIVELOG DELETE INPUT;
DELETE NOPROMPT OBSOLETE;
}

LIST GLOBAL SCRIPT NAMES;

CREATE GLOBAL SCRIPT level0_backup COMMENT 'level 0 incremental database and


archivelog backup'
{
BACKUP INCREMENTAL LEVEL 0 DATABASE PLUS ARCHIVELOG;

CREATE GLOBAL SCRIPT level1_backup COMMENT 'level 1 incremental database and


archivelog backup'
{
BACKUP INCREMENTAL LEVEL 1 DATABASE PLUS ARCHIVELOG;
DELETE NOPROMPT OBSOLETE;
}
REPLACE GLOBAL SCRIPT level0_backup COMMENT 'level 0 incremental database and
archivelog backup'
{
BACKUP INCREMENTAL LEVEL 0 DATABASE PLUS ARCHIVELOG;
DELETE NOPROMPT OBSOLETE;
}

Creating Stored Scripts: CREATE SCRIPT

Make sure RMAN is connected to the right target database and the recovery
catalog.
Then run the CREATE SCRIPT command, as shown in this example:

CREATE SCRIPT full_backup


{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE NOPROMPT OBSOLETE;
}

Examine the output. If no errors are displayed, then the script was
successfully created and stored in the recovery catalog.
For a global script, the syntax is similar:

CREATE GLOBAL SCRIPT global_full_backup


{
BACKUP DATABASE PLUS ARCHIVELOG;

DELETE NOPROMPT OBSOLETE;


}

Export-Catalog

The database holding the rman catalog should be protected against information loss,
the minimum level of protection can be implemented by executing a full export of
the catalog schema.
In case of catalog loss an import of the schema on a new or existing database will
make the catalog available again.

e.g. - exp $rmanuser/$rmanpwd@$rmandb file=rman-catalog-export.dmp


owner=rman feedback=100

exp rman/rman@db1 file=rman-catalog-export.dmp owner=rman feedback=100

Query-catalog

In some specific situations it may be useful to query directly the recovery


catalog. to do so we need to know the
Database ID (dbid) and the DB Key of the database we want to query data for on the
recovery catalog.

sqlplus "sys/password@db1 as sysdba"


select dbid from v$database;

sqlplus "rman/rman@catdb

select * from rc_database;

Get-catalog-version

how to get the catalog version on the rman catalog database

sqlplus "rman/rman@catdb

SELECT * FROM rcver;

Upgrade-catalog

How to upgrade the catalog to the last version, the upgrade command needs to be
entered twice to get it executed.

rman TARGET sys/shad@db1 CATALOG rman/rman@catdb


UPGRADE CATALOG;
UPGRADE CATALOG;

Unregister-database

If a database is not longer required on the rman catalog it can be unregistered.


This command needs to be executed with the 'noprompt' option if run from within a
script,
otherwise it assumes NO as response to the confirmation request.

Note that rman metadata is always stored also on the controlfile, if a database is
unregistered from the catalog, it can be afterwards registered again and all
backups contained
in the controlfile will be cataloged

rman TARGET sys/password@db1 CATALOG rman/rman@catdb


UNREGISTER DATABASE;

Drop-catalog

An rman catalog can be removed with the drop catalog command. If executed from a
script the command needs to be entered twice to get it run.

rman catalog rman/rman@catdb


DROP CATALOG;

=========================
BACKUP PRACTICAL
=========================

backup database;
backup datafile 5;
backup datafile 3;
backup datafile 2;
backup datafile 1;
backup database plus archivelog;
backup archivelog all;

===================================================================================
======================

export ORACLE_SID=db1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
$ORACLE_HOME/bin/rman target sys@db1/shad catalog rman@orcl/rman <<EOF
run
{
sql 'alter system archive log current';
backup database include current controlfile plus archivelog;

crosscheck backupset;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
}
EOF

==================================================================

#!/bin/bash
export ORACLE_SID=db1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
rman target sys/shad@db1 catalog rman/rman@orcl <<EOF
run
{
sql 'alter system archive log current';
backup database include current controlfile plus archivelog;
crosscheck backupset;
crosscheck archivelog all;
delete noprompt expired backup;
delete noprompt expired archivelog all;
}

======================================================================

Hot_full_rman_bkp_scirpt
Database Version : 10.1.0.2.0
OS platform : Window XP sp2
--------------------------------
Archive log >>> Enabled
Hot Backup
--------------------------------
My backup procedure.
Fri Sat Sun Mon Tue Wed Thur Fri

Incremental Level 0 - - - - - - 0
Incremental Level - 1 1 - 1 1 1 1
Inc_level_cumulative - - - 1 - - - -
---------------------------------------------------------------------
Incremental Level 0 Script

Backup.rcv file content


CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE disk RATE 2M;

RUN
{
DELETE NOPROMPT OBSOLETE;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
ALLOCATE CHANNEL C1 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C2 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C3 DEVICE TYPE DISK MAXPIECESIZE 100M;
BACKUP INCREMENTAL LEVEL 0 DATABASE TAG WEEKLY_THURSDAY_0_HOTORCL3_BKP;
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP DATABASE ARCHIVELOG ALL DELETE ALL INPUT TAG WEEKLY_THURSDAY_0_HOTORCL3_BKP;
BACKUP VALIDATE DATABASE;
}

-------------------------------------------------
Incremental Level 1 Script
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE disk RATE 2M;

RUN
{
ALLOCATE CHANNEL C1 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C2 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C3 DEVICE TYPE DISK MAXPIECESIZE 100M;
BACKUP INCREMENTAL LEVEL 1 DATABASE TAG INCR_LvL_1_HotORCL3_BKP;
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP DATABASE ARCHIVELOG ALL TAG INCR_LvL_1_HOTOTCL3_BKP;
}

-----------------------------------------------------------------
Incremental_cumulative_level_1 script

CONFIGURE RETENTION POLICY TO REDUNDANCY 2;


CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CHANNEL DEVICE TYPE disk RATE 2M;

RUN
{
ALLOCATE CHANNEL C1 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C2 DEVICE TYPE DISK MAXPIECESIZE 100M;
ALLOCATE CHANNEL C3 DEVICE TYPE DISK MAXPIECESIZE 100M;
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE TAG INCR_LVL_1_CUM_HOTORCL3_BKP;
SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP DATABASE ARCHIVELOG ALL TAG INCR_LVL_1_CUM_HOTORCL3_BKP;
}

---------------------------------------------------------

Above backup procedure i scheduled every day 11.00 pm according backup procedure.
for that create one windows NT COMMAND script.
My command script file is.
backup.cmdbelow is contents.
c:\oracle\product\10.1.0\db_1\bin\RMAN TARGET /@db02 CATALOG rman/cat@catdb
CMDFILE=d:\bkp_scripts\db02\backup.rcv LOG=d:\bkp_scripts\db02\backup.log

WEEKLY :
Code: [Select all] [Show/ hide]
#*** Weekly RMAN Script weekly_full.rman
CONNECT TARGET /

#*** Weekly full controlfile backup


BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_CONTROLFILE'
FORMAT '/srv/oradata/backups/weekly_controlfile_%d_t%t_s%s_p%p'
CURRENT CONTROLFILE;

#*** Weekly full spfile backup


BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_SPFILE'
FORMAT '/srv/oradata/backups/weekly_spfile_%d_t%t_s%s_p%p'
SPFILE;

#*** Weekly full database plus archivelog backup


BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_DATABASE'
FORMAT '/srv/oradata/backups/weekly_database_%d_t%t_s%s_p%p'
DATABASE;

#*** Weekly full archivelog backup


change archivelog all validate;
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_ARCHIVELOG'
FORMAT '/srv/oradata/backups/weekly_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-7';

#*** Remove old backups and archivelogs


# probabile il backup dell'archivelog lo considera in delete backup,
# quindi per avere 2 copie di weekly e daily (sia bkp che arc) basta sysdate-10
(>7) a backup
# e bastera' un sysdate-3 per gli archivelog che stanno sul flash-recovery-area
# un occhio a 'LIST COPY' 'LIST ARCHIVELOG ALL' mostra lo stesso risultato, ovvero
gli arc sulla flash
DELETE BACKUP COMPLETED BEFORE 'SYSDATE-10' DEVICE TYPE DISK;
DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-3';

#*** Maintenance steps


CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;

EXIT;

RMAN WEEKLY, DAILY AND HOURLY BACKUP SCRIPT

WEEKLY: RMAN BACKUP

#*** Weekly RMAN Script weekly_full.rman


CONNECT TARGET /

#*** Weekly full controlfile backup


BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_CONTROLFILE'
FORMAT '/srv/oradata/backups/weekly_controlfile_%d_t%t_s%s_p%p'
CURRENT CONTROLFILE;

#*** Weekly full spfile backup


BACKUP AS COPY
DEVICE TYPE DISK
TAG = 'WEEKLY_SPFILE'
FORMAT '/srv/oradata/backups/weekly_spfile_%d_t%t_s%s_p%p'
SPFILE;

#*** Weekly full database plus archivelog backup


BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_DATABASE'
FORMAT '/srv/oradata/backups/weekly_database_%d_t%t_s%s_p%p'
DATABASE;

#*** Weekly full archivelog backup


change archivelog all validate;
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';

BACKUP CHECK LOGICAL


AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 0
DEVICE TYPE DISK
TAG = 'WEEKLY_ARCHIVELOG'
FORMAT '/srv/oradata/backups/weekly_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-7';

#*** Remove old backups and archivelogs


# probabile il backup dell'archivelog lo considera in delete backup,
# quindi per avere 2 copie di weekly e daily (sia bkp che arc) basta sysdate-10
(>7) a backup
# e bastera' un sysdate-3 per gli archivelog che stanno sul flash-recovery-area
# un occhio a 'LIST COPY' 'LIST ARCHIVELOG ALL' mostra lo stesso risultato, ovvero
gli arc sulla flash
DELETE BACKUP COMPLETED BEFORE 'SYSDATE-10' DEVICE TYPE DISK;
DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-3';

#*** Maintenance steps


CROSSCHECK COPY;
CROSSCHECK BACKUP;
CROSSCHECK ARCHIVELOG ALL;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;

EXIT;

DAILY: RMAN BACKUP

#*** Daily RMAN Script daily_comulative.rman


CONNECT TARGET /

#*** Daily full database backup


BACKUP CHECK LOGICAL
AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1 CUMULATIVE
DEVICE TYPE DISK
TAG = 'DAILY_COMULATIVE_DATABASE'
FORMAT '/srv/oradata/backups/daily_comulative_database_%d_t%t_s%s_p%p'
DATABASE;

#*** Daily full archivelog backup


change archivelog all validate;
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';

BACKUP CHECK LOGICAL


AS COMPRESSED BACKUPSET
INCREMENTAL LEVEL = 1 CUMULATIVE
DEVICE TYPE DISK
TAG = 'DAILY_COMULATIVE_ARCHIVELOG'
FORMAT '/srv/oradata/backups/daily_comulative_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-3';

#*** Maintenance steps


DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED COPY;
DELETE NOPROMPT EXPIRED BACKUP;
DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;

EXIT;

HOURLY: RMAN BACKUP

#*** Hourly RMAN Script hourly_incremental.rman


CONNECT TARGET /

#*** Hourly incremental database backup


BACKUP CHECK LOGICAL
AS BACKUPSET
INCREMENTAL LEVEL 1
DEVICE TYPE DISK
TAG = 'HOURLY_INCREMENTAL_DATABASE'
FORMAT '/srv/oradata/backups/hourly_incremental_database_%d_t%t_s%s_p%p'
DATABASE;

#*** Hourly incremental archivelog backup


BACKUP CHECK LOGICAL
AS BACKUPSET
INCREMENTAL LEVEL 1
DEVICE TYPE DISK
TAG = 'HOURLY_INCREMENTAL_ARCHIVELOG'
FORMAT '/srv/oradata/backups/hourly_incremental_archivelog_%d_t%t_s%s_p%p'
ARCHIVELOG FROM TIME 'SYSDATE-1';

EXIT;

====================================