0% found this document useful (0 votes)
258 views6 pages

Rman

The document provides instructions for performing various RMAN backup and recovery tasks including: 1) Creating an RMAN catalog, registering and unregistering databases from the catalog, and resyncing the catalog. 2) Performing full and incremental backups of databases and archivelogs along with deleting obsolete backups. 3) Restoring and recovering databases to a point in time using archived redo logs. 4) Showing control file backup records and checking the status of RMAN backup jobs. 5) Running RMAN commands via scripts without hanging the terminal session.

Uploaded by

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

Rman

The document provides instructions for performing various RMAN backup and recovery tasks including: 1) Creating an RMAN catalog, registering and unregistering databases from the catalog, and resyncing the catalog. 2) Performing full and incremental backups of databases and archivelogs along with deleting obsolete backups. 3) Restoring and recovering databases to a point in time using archived redo logs. 4) Showing control file backup records and checking the status of RMAN backup jobs. 5) Running RMAN commands via scripts without hanging the terminal session.

Uploaded by

Shoaib Shaikh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

run {

allocate channel c1 type disk;


allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
backup as compressed backupset format='/backup/clone/CLONE_%U.rman' DATABASE PLU
S ARCHIVELOG;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

Create a catalog
===============
create a tablespace
create a user
grant connect, resource, recovery_catalog_owner to user
rman catalog user/pass@db
create catalog tablespace "<tablespace_name>";
Note. <tablespace_name> is case sensitive (i.e. it must be uppercase)
Note. If you get the error 'rman: can't open catalog', make sure that oracle's r
man is being run (which rman). X11 also has a command called rman. Rename it if
necessary.

Register a database
================
Note. ensure the target db has a password file
rman catalog user/pass@rmandb target user/pass@db
Register database;

Un-register a database
====================
sqlplus user/pass@rmandb
select * from rc_database;
select db_key, db_id from db;
execute dbms_rcvcat.unregisterdatabase(<db_key>, <db_id>);

Reset the catalog after a restlogs on the target


=======================================
reset database;

Resync the catalog with the target controlfile


=====================================
resync catalog;

Delete a backup
==============
allocate channel...
delete backuppiece <number>;
release channel;
Oracle to how to purge old RMAN backups
======================================
Oracle runs on Linux, therefore I must be an Oracle expert (so goes management t
hinking). Here s how to correctly purge old RMAN backups when storage runs out of
space (thanks Nakrob):
Do not use rm to remove files. You must do it via RMAN.
$ export NLS_DATE_FORMAT='DD-MM-YY HH24:MI'
$ rman target / NOCATALOG
RMAN > crosscheck backupset;
This command will verify whether backup file is still on media.
If it is unavailable, RMAN will mark it as UNAVAILABLE or EXPIRED.
RAMN > delete expired backupset;
or
RMAN > delete expired backup;
Note : If you manually rename or zip RMAN backup files, you must manually remove
it from disk since RMAN
does not recognize them.
RMAN > report obsolete;
The command lists all backups rendered obsolete based on rentention policy.
Current Retention Policy is 'Recovery WINDOW OF 30 DAYS'.
RMAN > delete obsolete;
RMAN > list backup summary;
It will show all backupset info kept in RMAN repository.
If you want to see what RMAN keeps in each backupset, run 'list backupset N' whe
re N is Backupset ID.
RMAN > delete backupset N;
or
RMAN > delete backupset; (to delete all backups)

Once fair amount of space is reclaimed, do full backup.


Not sure how much full back space is needed but not less than 20G.
RMAN > backup database;
RMAN > list backup;
Full backup may have more than one backupset.
Look for last backupsets. It will list backup db files.
RMAN > delete obsolete;
Rerun this command to delete unwanted existing backupsets (if have) after comple
ted full backup.
Backup a database
=================
backup database plus archivelog format '/u01/ora_backup/rman/%d_%u_%s';
run {
allocate channel t1 type disk;
backup current controlfile format '/u01/ora_backup/rman/%d_%u_%s';
backup database format '/u01/ora_backup/rman/%d_%u_%s';
backup archivelog all delete input format '/u01/ora_backup/rman/arch_%d_%u_%s';
release channel t1;
}
run {
allocate channel t1 type disk;
backup archivelog all delete input format '/u01/ora_backup/rman/arch_%d_%u_%s';
release channel t1;
}
Cold backup (archivelog or noarchivelog mode)
run {
allocate channel t1 type disk;
shutdown immediate;
startup mount;
backup database include current controlfile format '/u01/ora_backup/rman/%d_%u_%
s';
alter database open;
}
run {
allocate channel t1 type disk;
backup archivelog all delete input;
}

Restore/recover a database
=========================
Full restore and recovery
startup nomount;
run {

allocate channel t1 type


allocate channel t2 type
allocate channel t3 type
allocate channel t4 type
restore controlfile;
restore archivelog all;
alter database mount;
restore database;
recover database;

disk;
disk;
disk;
disk;

}
sql 'alter database open resetlogs';
Restore and roll forward to a point in time
startup nomount;
run {
set until time ="to_date('30/08/2006 12:00','dd/mm/yyyy hh24:mi')";
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
restore controlfile;
restore archivelog all;
alter database mount;
restore database;
recover database;
}
sql 'alter database open resetlogs';
If the archive logs are already in place:
startup mount;
run {
set until time ="to_date('08/02/2007 14:00','dd/mm/yyyy hh24:mi')";
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
restore database;
recover database;
}
sql 'alter database open resetlogs';
startup mount;
run {
allocate channel t1 type disk;
recover database;
}

Show the controlfile backup record


==============================
set pages 999 lines 100
col name format a60
break on set_stamp skip 1
select set_stamp

,
,
from
,
where
and
order
/

to_char(ba.completion_time, 'HH24:MI DD/MM/YY') finish_time


df.name
v$datafile
df
v$backup_datafile
ba
df.file# = ba.file#
ba.file# != 0
by set_stamp, ba.file#

Misc commands
===============
list backupset;
list backup of database;
list backup of archivelog all;
report obsolete;
report obsolete redundancy = 2;
delete obsolete; - remove unneeded backups
restore database validate; - check the backup
report unrecoverable;
report schema; - show current db files
crosscheck backup; - make sure the backups in the catalog still physically exist
delete expired backup; - delete epired backups found by crosscheck
rman target sys/*****@scr10 catalog rman/rman@dbarep
LIST BACKUPSET OF DATABASE;
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
DELETE OBSOLETE REDUNDANCY = 4 device type disk;
delete obsolete REDUNDANCY = 2 device type disk;
Delete archive log older than...
DELETE NOPROMPT ARCHIVELOG UNTIL TIME "SYSDATE-5"
Crosscheck the available archivelogs (fixes RMAN-06059)
change archivelog all crosscheck;
RMAN job status
===============
select
SESSION_KEY, INPUT_TYPE, STATUS,
to_char(START_TIME,'dd-mm-yyyy:hh24:mi:ss') start_time,
to_char(END_TIME,'dd-mm-yyyy:hh24:mi:ss') end_time,
time_taken_display,OUTPUT_BYTES/1024/1024 "size in MB"
from V$RMAN_BACKUP_JOB_DETAILS where INPUT_TYPE='DB INCR' order by SESSION_KEY;
OR
select operation,status,start_time,end_time from v$rman_status; OR
SELECT * FROM V$RMAN_OUTPUT; OR
select sid, start_time, totalwork sofar, (sofar/totalwork) * 100 pct_done from v
$session_longops where totalwork > sofar
AND
opname NOT LIKE '%aggregate%'
AND

opname like 'RMAN%';


nohup rman script
===============
nohup rman target / log=restore_db.log cmdfile=restore.rcv &
run {
allocate channed ch1 device type disk;
restore database;
}
using simple file
==============
nohup ksh -x restore.sh &
rman << EOF
connect target;
restore database;
exit
EOF

You might also like