Sei sulla pagina 1di 4

Oracle DBA Queries - Recovery Manager (RMAN) http://www.shutdownabort.com/dbaqueries/Backup_RMAN.

php

SQL> shutdown abort .com Search

About DBA QueriesDBA ScriptsQuick GuidestnsManagerOther Stuff Contact

Administration Backup - RMAN


Status
Session
Create a catalog
Init Parameters Register a database
User
Un-register a database
Roles Reset the catalog after a restlogs on the target
ASM Resync the catalog with the target controlfile
RAC 10gR2 Delete a backup
Job Scheduler
Backup a database
Advanced Queues
Restore/recover a database
Recycle bin
Show the controlfile backup record
Structure Misc commands
Tablespace
Objects
Indexes
Files
Create a catalog
Redo Logs
Undo
Constraints create a tablespace
Materialized view create a user
Partitions grant connect, resource, recovery_catalog_owner to user
Triggers
Clipboard
Performance
General
Locks DML rman catalog user/pass@db
Locks DDL create catalog tablespace "<tablespace_name>";
Waits
Clipboard
Statistics
Query Tuning Note. <tablespace_name> is case sensitive (i.e. it must be uppercase)
Memory
Statspack Note. If you get the error 'rman: can't open catalog', make sure that oracle's rman is being run (whic
AWR also has a command called rman. Rename it if necessary.
Backup
DataGuard Register a database
RMAN
Import Export Note. ensure the target db has a password file
Flashback rman catalog user/pass@rmandb target user/pass@db
Datapump
Miscellaneous Clipboard
Useful UNIX
utl_file register database;
SQL*Net
tnsnames.ora Clipboard
listener.ora
Un-register a database

sqlplus user/pass@rmandb
select * from rc_database;
select db_key, db_id from db;

Clipboard

execute dbms_rcvcat.unregisterdatabase(<db_key>, <db_id>);

1 of 4 12/23/2008 10:48 PM
Oracle DBA Queries - Recovery Manager (RMAN) http://www.shutdownabort.com/dbaqueries/Backup_RMAN.php

Clipboard

Reset the catalog after a restlogs on the target

reset database;

Clipboard

Resync the catalog with the target controlfile

resync catalog;

Clipboard

Delete a backup

allocate channel...
delete backuppiece <number>;
release channel;

Clipboard

Backup a database

backup database plus archivelog format '/u01/ora_backup/rman/%d_%u_%s';

Clipboard

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_
release channel t1;
}

Clipboard

run {
allocate channel t1 type disk;
backup archivelog all delete input format '/u01/ora_backup/rman/arch_%d_%u_
release channel t1;
}

Clipboard
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
alter database open;
}

Clipboard

run {

2 of 4 12/23/2008 10:48 PM
Oracle DBA Queries - Recovery Manager (RMAN) http://www.shutdownabort.com/dbaqueries/Backup_RMAN.php

allocate channel t1 type disk;


backup archivelog all delete input;
}

Clipboard

Restore/recover a database

Full restore and recovery


startup nomount;
run {
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';

Clipboard
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';

Clipboard
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';

Clipboard

startup mount;
run {
allocate channel t1 type disk;
recover database;

3 of 4 12/23/2008 10:48 PM
Oracle DBA Queries - Recovery Manager (RMAN) http://www.shutdownabort.com/dbaqueries/Backup_RMAN.php

Clipboard

Show the controlfile backup record

set pages 999 lines 100


col name format a60
break on set_stamp skip 1
select set_stamp
, to_char(ba.completion_time, 'HH24:MI DD/MM/YY') finish_time
, df.name
from v$datafile df
, v$backup_datafile ba
where df.file# = ba.file#
and ba.file# != 0
order by set_stamp, ba.file#
/

Clipboard

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
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;

Clipboard
Delete archive log older than...
DELETE NOPROMPT ARCHIVELOG UNTIL TIME "SYSDATE-5"

Clipboard
Crosscheck the available archivelogs (fixes RMAN-06059)
change archivelog all crosscheck;

Clipboard
Copyright© 2007-2008 Andrew Barry

4 of 4 12/23/2008 10:48 PM

Potrebbero piacerti anche