In this article we have listed the most useful RMAN commands .

1. Take full backup(incremental level 0 of the database)

rman target /
configure backup optimization on;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/backup/fullbackup/%F';
configure maxsetsize to unlimited;
configure device type disk parallelism 4;


run
{
allocate channel c1 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c2 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c3 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c4 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G
backup  as compressed backupset incremental level 0  check logical database plus archivelog;
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}

2. Take incremental backup:

rman target /
set echo on;
configure backup optimization on;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/backup/fullbackup/%F';
configure maxsetsize to unlimited;
configure device type disk parallelism 4;


run
{
allocate channel c1 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c2 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c3 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c4 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G
backup  as compressed backupset incremental level 1  check logical database plus archivelog;
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}

3. Take archive log backup:

rman target /
set echo on;
configure backup optimization on;
configure controlfile autobackup on;
configure controlfile autobackup format for device type disk to '/backup/fullbackup/%F';
configure maxsetsize to unlimited;
configure device type disk parallelism 4;


run
{
allocate channel c1 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c2 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c3 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G;
allocate channel c4 type disk format '/backup/fullbackup/%I-%Y%M%D-%U' maxpiecesize 3G
backup archivelog all FILESPERSET=4;
delete noprompt archivelog all completed before 'SYSDATE-3';
release channel c1 ;
release channel c2 ;
release channel c3 ;
release channel c4 ;
}

4. Delete old archivelogs(without taking backup)

rman target /
DELETE noprompt force  ARCHIVELOG ALL COMPLETED BEFORE 'sysdate-1';
CROSSCHECK ARCHIVELOG ALL;
DELETE EXPIRED ARCHIVELOG ALL;

5. Apply archivelog policy on standby database:

RMAN> configure archivelog deletion policy to applied on standby;

6. backup/restore archivelogs between specific sequence:

-- In standalone:
RMAN>backup format ‘/export/dump/%d_%s_%p_%c_%t.arc.rman’ archivelog from sequence 100 until sequence 105;

-- In rac for particular thread:

RMAN>backup format ‘/export/dump/%d_%s_%p_%c_%t.arc.rman’ archivelog from sequence 100 until sequence 102 thread 2;



-- List and restore:

RMAN> list archivelog sequence between 10 and 20 ;

RMAN> restore archivelog sequence between 10 and 20 ;

7 . backup tablespace or datafile backup:

RMAN> backup tablespace users to destination '/filedb/backp/database';

RMAN> BACKUP DATAFILE '/u01/apporacle/users01.dbf' to destination '/filedb/backp/database';

-- backup to default location:

RMAN> BACKUP DATAFILE '/u01/apporacle/users01.dbf';

8. Enable block change tracking:

SQL> select name from v$database;
 
NAME
---------
TESTDB
 
SQL> select filename,status from v$block_change_tracking;
 
FILENAME
--------------------------------------------------------------------------------
STATUS
----------
 
DISABLED
 

SQL> alter database enable block change tracking using file '/export/home/oracle/RMAN/TESTDB/TRACKING_FILE/block_change_TESTDB.log';
 
Database altered.
 

9. View and modify rman configuration details:

RMAN>show configuration
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE 'SBT_TAPE' PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE' PARMS 'SBT_LIBRARY=mylibrary.disksbt,ENV=(BACKUP_PARAM=value)';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/disk1/oracle/dbs/snapcf_ev.f'; # default

-- Modify configuration:

RMAN>CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;

RMAN>CONFIGURE ENCRYPTION FOR DATABASE ON;

11. Monitor rman backup:

alter session set nls_date_format='dd-mon-yyyy hh24:mi:ss';

set lines 180
col TIME_TAKEN_DISPLAY format a30
col OUTPUT_BYTES_DISPLAY format a30
col status format a10
col OUTPUT_DEVICE_TYPE format a15
select start_time,end_time,output_device_type,status,input_type,output_bytes_display,time_taken_display
from V$RMAN_BACKUP_JOB_DETAILS
order by start_time asc;




SELECT START_TIME, SOFAR, TOTALWORK,round(TIME_REMAINING/60,2) "TIME_REMAINING(mins)",ROUND(SOFAR/TOTALWORK*100,2) "%COMPLETE" FROM GV$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%' AND TOTALWORK != 0 AND OPNAME LIKE '%aggregate%' AND SOFAR <> TOTALWORK;


12.Monitor rman restore throughput:

set linesize 126
column Pct_Complete format 99.99
column client_info format a25
column sid format 999
column MB_PER_S format 999.99
select s.client_info,
l.sid,
l.serial#,
l.sofar,
l.totalwork,
round (l.sofar / l.totalwork*100,2) "Pct_Complete",
aio.MB_PER_S,
aio.LONG_WAIT_PCT
from v$session_longops l,
v$session s,
(select sid,
serial,
100* sum (long_waits) / sum (io_count) as "LONG_WAIT_PCT",
sum (effective_bytes_per_second)/1024/1024 as "MB_PER_S"
from v$backup_async_io
group by sid, serial) aio
where aio.sid = s.sid
and aio.serial = s.serial#
and l.opname like 'RMAN%'
and l.opname not like '%aggregate%'
and l.totalwork != 0
and l.sofar <> l.totalwork
and s.sid = l.sid
and s.serial# = l.serial#
order by 1;

13. RMAN CHECKSYNTAX command:

RMAN CHECKSYNTAX:
check the syntax of RMAN commands interactively without actually executing the commands.Use the command-line argument CHECKSYNTAX to start the RMAN client in a mode in which it only parses the commands

$ rman checksyntax

Recovery Manager: Release 12.1.0.2.0 - Production on Sun Jan 29 12:04:24 2017

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

RMAN> backup database;

The command has no syntax errors

14. List command in rman:

RMAN> list backup of database summary;
RMAN> LIST BACKUP OF DATAFILE 1;
RMAN>LIST BACKUP OF TABLESPACE DATA;
RMAN>LIST BACKUP OF ARCHIVELOG ALL;
RMAN>LIST BACKUP OF CONTROLFILE;
RMAN>LIST INCARNATION;

SEE ALSO: