Rman Cheat Sheet: Start Command
Rman Cheat Sheet: Start Command
Rman Cheat Sheet: Start Command
UNREGISTER command
CREATE CATALOG command Unregister a Oracle database from the recovery catalog.
Create Oracle schema for the recovery catalog. RMAN> UNREGISTER DATABASE;
RMAN> CREATE CATALOG; RMAN> UNREGISTER DATABASE NOPROMPT;
RMAN> CREATE CATALOG TABLESPACE rmants; RMAN> UNREGISTER DATABASE prod1;
RMAN> CREATE VIRTUAL CATALOG; RMAN> UNREGISTER DATABASE prod2 NOPROMPT;
RMAN> SQL "EXEC RMAN> UNREGISTER DB_UNIQUE_NAME prod2;
catown.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG"; RMAN> UNREGISTER DB_UNIQUE_NAME prod1 NOPROMPT;
RMAN> UNREGISTER DB_UNIQUE_NAME prod2 INCLUDING
BACKUPS;
RMAN> UNREGISTER DB_UNIQUE_NAME prod3 INCLUDING
BACKUPS NOPROMPT;
DROP CATALOG command
Remove Oracle schema from the recovery catalog.
RMAN> DROP CATALOG; GRANT command
Grant privileges to a recovery catalog user.
RMAN> GRANT CATALOG FOR DATABASE prod1 TO vpc1;
RMAN> GRANT REGISTER DATABASE TO bckop2;
RMAN> GRANT RECOVERY_CATALOG_OWNER TO rmanop1,
RESYNC CATALOG command rmanop3;
Perform a full resynchronization, which creates a snapshot control
file and then copies any new or changed information from that
snapshot control file to the recovery catalog. REVOKE command
RMAN> RESYNC CATALOG; Revoke privileges from a recovery catalog user.
RMAN> RESYNC CATALOG FROM DB_UNIQUE_NAME prod_db; RMAN> REVOKE CATALOG FOR DATABASE prod1 FROM vpc1;
RMAN> RESYNC CATALOG FROM DB_UNIQUE_NAME ALL; RMAN> REVOKE REGISTER DATABASE FROM bckop2;
RMAN> REVOKE RECOVERY_CATALOG_OWNER FROM bckop;
2 TECHGOEASY.COM
RMAN CHEAT SHEET
3 TECHGOEASY.COM
RMAN CHEAT SHEET
4 TECHGOEASY.COM
RMAN CHEAT SHEET
RMAN> BACKUP ARCHIVELOG NOT BACKED UP 2 TIMES; RMAN> BACKUP AS COPY REUSE TARGETFILE
RMAN> BACKUP ARCHIVELOG COMPLETION TIME BETWEEN '/u01/oracle/11.2.0.2/dbs/orapwcrd' AUXILIARY FORMAT
'SYSDATE-28' AND 'SYSDATE-7'; '/u01/oracle/11.2.0.2/dbs/orapwcrd';
RMAN> BACKUP FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE RMAN> BACKUP AS COPY CURRENT CONTROLFILE FOR STANDBY
'%arc_dest%'; AUXILIARY format '+DATA/crd/data1/control01.ctl';
5 TECHGOEASY.COM
RMAN CHEAT SHEET
6 TECHGOEASY.COM
RMAN CHEAT SHEET
ALLOCATE CHANNEL c1 DEVICE TYPE sbt; Delete backups and copies, remove references to them from the
RESTORE CONTROLFILE; recovery catalog, and update their control file records to status
ALTER DATABASE MOUNT; DELETED.
RESTORE DATABASE;
}
With 12c RMAN> DELETE OBSOLETE;
RMAN> DELETE NOPROMPT OBSOLETE;
RMAN>RESTORE PLUGGABLE DATABASE PDB1, PDB2; RMAN> DELETE NOPROMPT OBSOLETE RECOVERY WINDOW OF 7
DAYS;
RMAN> DELETE EXPIRED BACKUP;
RMAN> DELETE EXPIRED BACKUP DEVICE TYPE sbt;
RECOVER command RMAN> DELETE BACKUP OF DATABASE LIKE '/tmp%';
Perform media recovery from RMAN backups and copies. Apply redo RMAN> DELETE NOPROMPT EXPIRED BACKUP OF TABLESPACE users
log files and incremental backups to datafiles or data blocks restored COMPLETED BEFORE 'SYSDATE-14';
from backup or datafile copies, to update them to a specified time. RMAN> DELETE BACKUP OF SPFILE TABLESPACE users DEVICE TYPE
SBT;
RMAN> RECOVER DATABASE;
RMAN> RECOVER DATABASE NOREDO; RMAN> DELETE ARCHIVELOG ALL;
RMAN> RECOVER DATABASE SKIP TABLESPACE temp; RMAN> DELETE ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-2';
RMAN> RECOVER DATABASE SKIP FOREVER TABLESPACE exam; RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE
RMAN> RECOVER DATABASE UNTIL SCN 154876; TYPE SBT;
RMAN> DELETE ARCHIVELOG ALL LIKE '%755153075%';
RMAN> RECOVER TABLESPACE users; RMAN> DELETE ARCHIVELOG UNTIL SEQUENCE=79228;
RMAN> RECOVER TABLESPACE dwh DELETE ARCHIVELOG MAXSIZE RMAN> DELETE FORCE ARCHIVELOG ALL COMPLETED BEFORE
2M; 'sysdate-1.5';
RMAN> RECOVER DATAFILE 33; RMAN> DELETE FORCE ARCHIVELOG UNTIL SEQUENCE=16364;
RMAN> RECOVER DATAFILE 3 BLOCK 116 DATAFILE 4 BLOCK 10; RMAN> DELETE NOPROMPT ARCHIVELOG UNTIL SEQUENCE = 7300;
RMAN> RECOVER DATAFILE 2 BLOCK 204 DATAFILE 9 BLOCK 109 RMAN> DELETE EXPIRED ARCHIVELOG ALL;
FROM TAG=sundaynight; RMAN> DELETE NOPROMPT EXPIRED ARCHIVELOG ALL;
RMAN> RECOVER DATAFILECOPY '/disk1/img.df' UNTIL TIME RMAN> DELETE BACKUPSET 101, 102, 103;
'SYSDATE-7'; RMAN> DELETE NOPROMPT BACKUPSET TAG weekly_bkup;
RMAN> RECOVER COPY OF DATABASE WITH TAG 'incr'; RMAN> DELETE FORCE NOPROMPT BACKUPSET TAG weekly_bkup;
RMAN> RECOVER COPY OF DATABASE WITH TAG 'upd' UNTIL TIME
'SYSDATE - 7'; RMAN> DELETE DATAFILECOPY
RMAN> RECOVER CORRUPTION LIST; "+DG_DATA/db/datafile/system.259.699468079";
RMAN> DELETE CONTROLFILECOPY '/tmp/cntrlfile.copy';
Restore and recover the whole database RMAN> DELETE BACKUP DEVICE TYPE SBT;
RMAN> STARTUP FORCE MOUNT; RMAN> DELETE BACKUP DEVICE TYPE DISK;
RMAN> RESTORE DATABASE; RMAN> DELETE COPY;
RMAN> RECOVER DATABASE; RMAN> DELETE EXPIRED COPY;
RMAN> ALTER DATABASE OPEN; RMAN> DELETE COPY TAG 'lastest';
DUPLICATE command
DELETE command Use backups of the target database to create a duplicate database
7 TECHGOEASY.COM
RMAN CHEAT SHEET
that we can use for testing purposes or to create a standby RMAN> SWITCH DATAFILE ALL;
database. RMAN> SWITCH DATAFILE '/disk1/tols.dbf' TO DATAFILECOPY
RMAN> DUPLICATE TARGET DATABASE; '/disk2/tols.copy';
RMAN> DUPLICATE TARGET DATABASE TO <DB_NAME>; RMAN> SWITCH DATAFILE
RMAN> DUPLICATE TARGET DATABASE TO test "+DG_OLD/db/datafile/sysaux.260.699468081" TO COPY;
PFILE=/u01/apps/db/inittest.ora; RMAN> SWITCH TEMPFILE 1;
RMAN> DUPLICATE TARGET DATABASE TO <DB_NAME> RMAN> SWITCH TEMPFILE 1 TO '/newdisk/dbs/temp1.f';
NOFILENAMECHECK; RMAN> SWITCH TEMPFILE ALL;
RMAN> DUPLICATE DATABASE 'prod' DBID 139525561 TO 'dupdb' RMAN> SWITCH CLONE DATAFILE ALL;
NOFILENAMECHECK;
RMAN> DUPLICATE DATABASE TO <DB_NAME> NOFILENAMECHECK
BACKUP LOCATION '/apps/oracle/backup';
RMAN> DUPLICATE TARGET DATABASE TO dup FROM ACTIVE
DATABASE NOFILENAMECHECK PASSWORD FILE SPFILE; CATALOG command
Add information about file copies and user-managed backups to the
RMAN> DUPLICATE TARGET DATABASE TO dupdb catalog repository.
LOGFILE GROUP 1 RMAN> CATALOG DATAFILECOPY '<file location>';
('?/dbs/dupdb_log_1_1.f','?/dbs/dupdb_log_1_2.f') SIZE 200K, RMAN> CATALOG DATAFILECOPY '<file location>' LEVEL 0;
GROUP 2 ('?/dbs/dupdb_log_2_1.f','?/dbs/dupdb_log_2_2.f') SIZE RMAN> CATALOG CONTROLFILECOPY '/disk3/backup/cf_copy.bkp';
200K REUSE; RMAN> CATALOG ARCHIVELOG '<arch location>’;
RMAN> DUPLICATE TARGET DATABASE TO dup FOR STANDBY FROM RMAN> CATALOG BACKUPPIECE '<backup piece location>;
ACTIVE DATABASE PASSWORD FILE SPFILE RMAN> CATALOG LIKE '/backup';
PARAMETER_VALUE_CONVERT '/disk1', '/disk2' RMAN> CATALOG START WITH '/fs2/arch';
SET DB_FILE_NAME_CONVERT '/disk1','/disk2' RMAN> CATALOG START WITH '/disk2/archlog' NOPROMPT;
SET LOG_FILE_NAME_CONVERT '/disk1','/disk2' RMAN> CATALOG START WITH '+FLASH';
SET SGA_MAX_SIZE 200M SET SGA_TARGET 125M; RMAN> CATALOG RECOVERY AREA;
8 TECHGOEASY.COM
RMAN CHEAT SHEET
CONNECT '@test1';
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt VALIDATE command
PARMS 'SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so, Examine a backup set and report whether its data is intact. RMAN
ENV=(OB_DEVICE_1=tape2)'; scans all of the backup pieces in the specified backup sets and looks
at the checksums to verify that the contents can be successfully
restored.
RMAN> VALIDATE BACKUPSET 218;
RMAN> VALIDATE BACKUPSET 3871, 3890;
RMAN> VALIDATE DATABASE;
RELEASE CHANNEL command RMAN> VALIDATE CHECK LOGICAL DATABASE;
Release a channel that was allocated with an ALLOCATE CHANNEL or RMAN> VALIDATE SKIP INACCESSIBLE DATABASE;
ALLOCATE CHANNEL FOR MAINTENANCE command. RMAN> VALIDATE COPY OF DATABASE;
RMAN> RELEASE CHANNEL; RMAN> VALIDATE TABLESPACE dwh;
RMAN> RELEASE CHANNEL c1; RMAN> VALIDATE COPY OF TABLESPACE dwh;
RMAN> VALIDATE DATAFILE 2;
RMAN> VALIDATE DATAFILE 4,8;
RMAN> VALIDATE DATAFILE 4 BLOCK 56;
RMAN> VALIDATE DATAFILE 8 SECTION SIZE = 200M;
BLOCKRECOVER command RMAN> VALIDATE CURRENT CONTROLFILE;
Will recover the corrupted blocks. RMAN> VALIDATE SPFILE;
RMAN> BLOCKRECOVER CORRUPTION LIST; RMAN> VALIDATE RECOVERY FILES;
RMAN> BLOCKRECOVER DATAFILE 8 BLOCK 22; RMAN> VALIDATE RECOVERY AREA;
RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233,235 DATAFILE 4 RMAN> VALIDATE DB_RECOVERY_FILE_DEST;
BLOCK 101;
RMAN> BLOCKRECOVER DATAFILE 2 BLOCK 12,13 DATAFILE 3 BLOCK
5,98,99 DATAFILE 4 BLOCK 19;
RMAN> BLOCKRECOVER DATAFILE 3 BLOCK 2,4,5 TABLESPACE sales
DBA 4194405,4194412 FROM DATAFILECOPY; SPOOL command
RMAN> BLOCKRECOVER TABLESPACE dwh DBA 4194404,4194405 Write RMAN output to a log file.
FROM TAG "weekly"; RMAN> SPOOL LOG TO '/tmp/spool.log';
RMAN> BLOCKRECOVER TABLESPACE dwh DBA 94404 RESTORE RMAN> SPOOL LOG TO '/tmp/backup.log' APPEND;
UNTIL TIME 'SYSDATE-2'; RMAN> SPOOL LOG OFF;
9 TECHGOEASY.COM
RMAN CHEAT SHEET
FORMAT '/tmp/test/%N.dbf'
FLASHBACK DATABASE command DB_FILE_NAME_CONVERT='/ui/prod/oracle/oradata/SEARCHP/data
Return the database to its state at a previous time or SCN. /', '/tmp/test';
RMAN> FLASHBACK DATABASE TO SCN 411010;
RMAN> FLASHBACK DATABASE TO RESTORE POINT 'before_update';
10 TECHGOEASY.COM