RMAN Commands

RMAN Commands

RMAN CONNECT COMMAND:- Connect command is used to connect database from RMAN command prompt. Below are valid command examples for connecting database from RMAN command prompt

RMAN>CONNECT TARGET;
RMAN>CONNECT TARGET /
RMAN>CONNECT TARGET sys@db1;
RMAN>CONNECT TARGET sys/pwd@db1;
RMAN>CONNECT CATALOG rman@catdb;
RMAN>CONNECT CATALOG rman/pwd@catdb;
RMAN>CONNECT AUXILIARY /
RMAN>CONNECT AUXILIARY rman@auxdb;
RMAN>CONNECT AUXILIARY rman/pwd@auxdb;

RMAN CATALOG COMMAND :- These command are used to create, sync, drop and import catalog. Below are the examples for CATALOG commands
 
RMAN>CREATE CATALOG;
RMAN>CREATE CATALOG TABLESPACE ;
RMAN>CREATE VIRTUAL CATALOG;
RMAN>DROP CATALOG;
RMAN>RESYNC CATALOG;
RMAN>RESYNC CATALOG FROM DB_UNIQUE_NAME proddb;
RMAN>RESYNC CATALOG FROM DB_UNIQUE_NAME ALL;
RMAN>IMPORT CATALOG cat@prodb;
RMAN>IMPORT CATALOG rcat@insdb DBID=2871507123;
RMAN>IMPORT CATALOG cat@prodb DBID=1844750987, 61738563;
RMAN>IMPORT CATALOG cat@prodb DB_NAME=prod;
RMAN>IMPORT CATALOG cat@prodb DB_NAME=prod1, prod2;
RMAN>IMPORT CATALOG rman/rman@catdb1 DB_NAME=prod1 NO UNREGISTER;
RMAN>IMPORT CATALOG rman/pwd@catdb NO UNREGISTER;

   
RMAN REGISTER/UNREGISTER DATABASE COMMAND :- Register database command is used to register database on RMAN catalog and same way we are using unregister database command to un-register database from RMAN catalog

RMAN>REGISTER DATABASE;
RMAN>UNREGISTER DATABASE;
RMAN>UNREGISTER DATABASE NOPROMPT;
RMAN>UNREGISTER DATABASE prodb;
RMAN>UNREGISTER DATABASE prodb NOPROMPT;
RMAN>UNREGISTER DB_UNIQUE_NAME prod1;
RMAN>UNREGISTER DB_UNIQUE_NAME prod1 NOPROMPT;
RMAN>UNREGISTER DB_UNIQUE_NAME prod2 INCLUDING BACKUPS;
RMAN>UNREGISTER DB_UNIQUE_NAME prod1 INCLUDING BACKUPS NOPROMPT;

STARTUP and SHUTDOWN COMMAND:-We are using STARTUP and SHUTDOWN command to start and shutdown database from RMAN command prompt

RMAN>SHUTDOWN;
RMAN>SHUTDOWN NORMAL;
RMAN>SHUTDOWN TRANSACTIONAL;
RMAN>SHUTDOWN IMMEDIATE;
RMAN>SHUTDOWN ABORT;

RMAN>STARTUP;
RMAN>STARTUP NOMOUNT;
RMAN>ALTER DATABASE MOUNT;
RMAN>ALTER DATABASE OPEN;
RMAN>STARTUP MOUNT;
RMAN>ALTER DATABASE OPEN RESETLOGS;
RMAN>STARTUP FORCE;
RMAN>STARTUP FORCE DBA;
RMAN>STARTUP PFILE='/u01/app/oracle/initprodb.ora';
RMAN>STARTUP FORCE DBA PFILE='/u01/app/oracle/initprodb.ora';
RMAN>STARTUP FORCE NOMOUNT;
RMAN>STARTUP FORCE MOUNT DBA PFILE=/tmp/inittrgt.ora;
RMAN>STARTUP AUXILIARY nomount;
BACKUP COMMAND :- Backup Command is used to take backup. Below are the available options with backup command

RMAN>BACKUP DATABASE;
RMAN>BACKUP DATABASE TAG='Full_backup';
RMAN>BACKUP DATABASE COMMENT='First_Week_backup';
RMAN>BACKUP TAG 'weekly_full_db_bkup' DATABASE MAXSETSIZE 500M;
RMAN>BACKUP DATABASE PLUS ARCHIVELOG;
RMAN>BACKUP MAXSETSIZE 500M DATABASE PLUS ARCHIVELOG;
RMAN>BACKUP DURATION 00:60 DATABASE;
RMAN>BACKUP DURATION 00:30 MINIMIZE TIME DATABASE;
RMAN>BACKUP DURATION 00:45 MINIMIZE LOAD DATABASE;
RMAN>BACKUP DATABASE KEEP FOREVER;
RMAN>BACKUP DATABASE KEEP UNTIL TIME=’SYSDATE+30’;
RMAN>BACKUP DATABASE UNTIL 'SYSDATE+365' NOLOGS;
RMAN>BACKUP DATABASE NOEXCLUDE;
RMAN>BACKUP DATABASE NOEXCLUDE KEEP FOREVER TAG='never_delete';
RMAN>BACKUP DATABASE SKIP READONLY;
RMAN>BACKUP DATABASE SKIP OFFLINE;
RMAN>BACKUP DATABASE SKIP INACCESSIBLE;
RMAN>BACKUP DATABASE SKIP READONLY SKIP OFFLINE SKIP INACCESSIBLE;
RMAN>BACKUP DATABASE FORCE; -- backup read only database also
RMAN>BACKUP DATABASE NOT BACKED UP;
RMAN>BACKUP DATABASE NOT BACKED UP SINCE TIME=’SYSDATE–3’;
RMAN>BACKUP NOT BACKED UP SINCE TIME 'SYSDATE-10' MAXSETSIZE 500M DATABASE PLUS ARCHIVELOG;
RMAN>BACKUP DATABASE COPIES=2;
RMAN>BACKUP DATABASE FORMAT '/disk1/backups/db_%U.bck'
TAG quarterly KEEP UNTIL TIME 'SYSDATE+365' RESTORE POINT Q1FY12;
RMAN>BACKUP DEVICE TYPE DISK DATABASE;
RMAN>BACKUP DEVICE TYPE sbt DATABASE PLUS ARCHIVELOG;
RMAN>BACKUP DEVICE TYPE sbt DATAFILECOPY FROM TAG 'latest' FORMAT 'df%f_%d';
RMAN>BACKUP DEVICE TYPE sbt ARCHIVELOG LIKE '/disk%arc%' DELETE ALL INPUT;
RMAN>BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14'DELETE INPUT;
RMAN>BACKUP CHECK LOGICAL DATABASE;
RMAN>BACKUP VALIDATE CHECK LOGICAL DATABASE;
RMAN>BACKUP VALIDATE DATABASE;
RMAN>BACKUP VALIDATE DATABASE ARCHIVELOG ALL;
RMAN>BACKUP TABLESPACE users;
RMAN>BACKUP TABLESPACE system, users;
RMAN>BACKUP TABLESPACE 4;
RMAN>BACKUP TABLESPACE users PLUS ARCHIVELOG;
RMAN>BACKUP TABLESPACE users INCLUDE CURRENT CONTROLFILE;
RMAN>BACKUP TABLESPACE users INCLUDE CURRENT CONTROLFILE PLUS ARCHIVELOG;
RMAN>BACKUP TABLESPACE users SECTION SIZE 100M;
RMAN>BACKUP SECTION SIZE 250M TABLESPACE users;
RMAN>BACKUP DATAFILE 1;
RMAN>BACKUP DATAFILE 1, 2, 3;
RMAN>BACKUP DATAFILE '/u01/data/..';
RMAN>BACKUP DATAFILE 1 PLUS ARCHIVELOG;
RMAN>BACKUP KEEP FOREVER FORMAT '?/dbs/%U_longterm.cpy' TAG longterm_bck DATAFILE 1 DATAFILE 2;
RMAN>BACKUP SECTION SIZE 500M DATAFILE 6;
RMAN>BACKUP ARCHIVELOG ALL;
RMAN>BACKUP ARCHIVELOG ALL DELETE INPUT;
RMAN>BACKUP ARCHIVELOG LIKE '/arch%' DELETE ALL INPUT;
RMAN>BACKUP ARCHIVELOG FROM TIME ‘SYSDATE–3’;
RMAN>BACKUP ARCHIVELOG FROM SEQUENCE 100;
RMAN>BACKUP ARCHIVELOG FROM SEQUENCE 999 DELETE INPUT;
RMAN>BACKUP ARCHIVELOG FROM SEQUENCE 123 DELETE ALL INPUT;
RMAN>BACKUP ARCHIVELOG FROM SEQUENCE 21531 UNTIL SEQUENCE 21590 FORMAT '/tmp/archive_backup.bkp';
RMAN>BACKUP ARCHIVELOG ALL FROM SEQUENCE 1200 DELETE ALL INPUT;
RMAN>BACKUP ARCHIVELOG NOT BACKED UP 2 TIMES;
RMAN>BACKUP ARCHIVELOG COMPLETION TIME BETWEEN 'SYSDATE-28' AND 'SYSDATE-7';
RMAN>BACKUP FORMAT='AL_%d/%t/%s/%p' ARCHIVELOG LIKE '%arc_dest%';

RMAN>BACKUP CURRENT CONTROLFILE;
OR
RMAN>SQL "ALTER DATABASE BACKUP CONTROLFILE TO '/tmp/bkctl.ctl'";
RMAN>BACKUP CURRENT CONTROLFILE TO '/backup/cntrlfile.copy';
RMAN>BACKUP CONTROLFILE COPY ‘/u10/backup/control.bkp’;
RMAN>BACKUP SPFILE;
RMAN>BACKUP DEVICE TYPE sbt SPFILE ARCHIVELOG ALL;
RMAN>BACKUP DEVICE TYPE sbt DATAFILECOPY ALL NODUPLICATES;
RMAN>BACKUP RECOVERY FILES;

BACKUP set
RMAN>BACKUP BACKUPSET ALL;
RMAN>BACKUP BACKUPSET ALL FORMAT = ‘/u01/.../backup_%u.bak’;
RMAN>BACKUP BACKUPSET COMPLETED BEFORE ‘SYSDATE-3’ DELETE INPUT;
RMAN>BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14' DELETE INPUT;
RMAN>BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
RMAN>BACKUP AS COMPRESSED BACKUPSET;
RMAN>BACKUP AS COMPRESSED BACKUPSET DEVICE TYPE DISK COPIES 2 DATABASE FORMAT '/disk1/db_%U', '/disk2/db_%U';
RMAN>BACKUP AS COMPRESSED BACKUPSET INCREMENTAL FROM SCN 796512 DATABASE TAG 'RMAN_RECOVERY';
RMAN>BACKUP AS BACKUPSET DATAFILE '$ORACLE_HOME/oradata/users01.dbf','$ORACLE_HOME/oradata/tools01.dbf';
RMAN>BACKUP AS BACKUPSET DATAFILECOPY ALL;
RMAN>BACKUP AS BACKUPSET DATAFILECOPY ALL NODUPLICATES;

IMAGE copy
RMAN>BACKUP AS COPY DATABASE;
RMAN>BACKUP AS COPY COPY OF DATABASE FROM TAG 'bkp' CHECK LOGICAL TAG 'dupbkp';
RMAN>BACKUP AS COPY TABLESPACE 8;
RMAN>BACKUP AS COPY TABLESPACE users;
RMAN>BACKUP AS COPY TABLESPACE system, tools, users, undotbs;
RMAN>BACKUP AS COPY DATAFILE 1;
RMAN>BACKUP AS COPY DATAFILE 2 FORMAT '/disk2/df2.cpy' TAG 'my_bkp';
RMAN>BACKUP AS COPY CURRENT CONTROLFILE;
RMAN>BACKUP AS COPY CURRENT CONTROLFILE FORMAT ‘/....’;
RMAN>BACKUP AS COPY ARCHIVELOG ALL;
RMAN>BACKUP AS COPY KEEP FOREVER NOLOGS CURRENT CONTROLFILE FORMAT '?/oradata/cf_longterm.cpy', DATAFILE 1 FORMAT '?/oradata/df1_longterm.cpy', DATAFILE 2 FORMAT '?/oradata/df2_longterm.cpy';
RMAN>BACKUP AS COPY DATAFILECOPY 'bar' FORMAT 'foobar';
RMAN>BACKUP AS COPY DATAFILECOPY '/disk2/df2.cpy' FORMAT '/disk1/df2.cpy';
RMAN>BACKUP AS COPY REUSE TARGETFILE '/u01/oracle/11.2.0.2/dbs/orapwcrd' AUXILIARY FORMAT '/u01/oracle/11.2.0.2/dbs/orapwcrd';

Incremental backups
RMAN>BACKUP INCREMENTAL LEVEL=0 DATABASE;
RMAN>BACKUP INCREMENTAL LEVEL=1 DATABASE;
RMAN>BACKUP INCREMENTAL LEVEL=0 DATABASE PLUS ARCHIVELOG;
RMAN>BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE;
RMAN>BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_bkp' DATABASE;
RMAN>BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'increment_bkp' DATABASE;
RMAN>BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 751986 DATABASE FORMAT '/tmp/incr_standby_%U';
RMAN>BACKUP INCREMENTAL FROM SCN 729684 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG 'FORSTANDBY';
RMAN>BACKUP BLOCKS ALL CHECK LOGICAL VALIDATE DATAFILE 1;



RMAN> show all;
RMAN> list backup;
RMAN> list backupset;
RMAN> list backup summary;
RMAN> list backupset of database;
RMAN> list backupset of database completed before '22-NOV-00';
RMAN> list backupset of archivelog all;
RMAN> list backup of archivelog all ;
RMAN> list backupset of tablespace users;
RMAN> list backup of tablespace SYSTEM;
RMAN> list backupset of datafile 1;
RMAN> list backup of controlfile;
RMAN> list backup by file;
RMAN> list copy of database;
RMAN> list copy of database archivelog all;

RMAN> allocate channel for maintenance type disk;
RMAN> configure channel device type disk clear ;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> report need backup days=2 database;
RMAN> report need backup days=10 tablespace TEMP;
RMAN> report need backup days=4 datafile 'D:\ORACLE\ORADATA\OR816\TEMP01.DBF';
RMAN> report schema;
RMAN> report obsolete;


Delete backups :-
RMAN> delete noprompt expired backup ;
RMAN> delete noprompt obsolete;
RMAN> delete archivelog all;
RMAN> delete expired archivelog all;
RMAN> delete archivelog all completed before 'sysdate -1';
RMAN> delete noprompt archivelog until time 'sysdate - 1';
RMAN> delete archivelog all backed up 1 times to device type disk completed before 'sysdate-1';

Verifying backups :-
RMAN> CROSSCHECK backup;
RMAN> CROSSCHECK copy;
RMAN> CROSSCHECK backup of database;
RMAN> CROSSCHECK backup of controlfile;
RMAN> CROSSCHECK archivelog all;

RMAN> crosscheck backupset;
RMAN> crosscheck controlfilecopy '/ora01/oracle/admin/BACKUP/demo/demo_controlfile_bak_03-15-11_19:59:11' ;

No comments:

Post a Comment