Thursday, January 15, 2015

Configuring RMAN Backup

Here I will explain how to configure very basic and very simple RMAN backup job to take daily backup (incremental level 0), which can be used by anyone at any OS platform and for any version of Oracle Database - difference will only be the file system paths which will be different in Windows and Unix based platforms.


Create rman.bat (
windows) or rman.sh (Unix based platforms)
This file will contain following line in it, which actually calls a text file containing RMAN code.
Windows
D:\oracle\12.1.0\dbhome_1\bin\rman target sys/<password>@mydb cmdfile D:\scripts\rman_backup.txt log d:\scripts\rman_backup.log

Unix
/u01/oracle/product/12.1.0/dbhome_1/bin/rman target sys/<password>@mydb cmdfile /u01/scripts/rman_backup.txt log /u01/scripts/rman_backup.log

Create rman_backup.txt
This file will contain following lines of RMAN code. Backup path should be changed based on your platform and backup location. This command will generate a log file “rman_backup.log” under /u01/scripts location.
run
{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup  format '/u01/backup/ora_%U.bak' incremental level 0 database;
backup  format '/u01/backup/arc_%U.bak' archivelog all delete input;
crosscheck backup;
delete noprompt obsolete ;
delete noprompt expired backup;
backup current controlfile format '/u01/backup/control_%U.bak';
}

Create a scheduler job (for Windows) or cron job (for Unix based platforms) in which we will call the rman.bat/rman.sh.

After running the job, output in rman_backup.log should be similar to the following.
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Jan 16 11:49:09 2015

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

connected to target database: CDB (DBID=1984282942)

RMAN> run
2> {
3> allocate channel dsk1 type disk;
4> allocate channel dsk2 type disk;
5> backup  format '/u01/backup/ora_%U.bak' incremental level 0 database;
6> backup  format '/u01/backup/arc_%U.bak' archivelog all delete input;
7> delete noprompt obsolete ;
8> crosscheck backup;
9> delete noprompt expired backup;
10> backup current controlfile format '/u01/backup/control_%U.bak';
11> }
12>
13>
using target database control file instead of recovery catalog
allocated channel: dsk1
channel dsk1: SID=263 device type=DISK

allocated channel: dsk2
channel dsk2: SID=282 device type=DISK

Starting backup at 16-JAN-15
channel dsk1: starting incremental level 0 datafile backup set
channel dsk1: specifying datafile(s) in backup set
input datafile file number=00001 name=+DATA/CDB/DATAFILE/system.257.867679079
input datafile file number=00004 name=+DATA/CDB/DATAFILE/undotbs1.264.867679351
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk2: starting incremental level 0 datafile backup set
channel dsk2: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/CDB/DATAFILE/sysaux.266.867678841
input datafile file number=00006 name=+DATA/CDB/DATAFILE/users.256.867679343
channel dsk2: starting piece 1 at 16-JAN-15
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0jpss0u9_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:01:45
channel dsk1: starting incremental level 0 datafile backup set
channel dsk1: specifying datafile(s) in backup set
input datafile file number=00009 name=+DATA/CDB/0B69FF6895963F6EE05328E7E7C06EFD/DATAFILE/sysaux.274.867680497
input datafile file number=00010 name=+DATA/CDB/0B69FF6895963F6EE05328E7E7C06EFD/DATAFILE/users.276.867680885
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk2: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0kpss0u9_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk2: backup set complete, elapsed time: 00:01:46
channel dsk2: starting incremental level 0 datafile backup set
channel dsk2: specifying datafile(s) in backup set
input datafile file number=00007 name=+DATA/CDB/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/sysaux.269.867679599
channel dsk2: starting piece 1 at 16-JAN-15
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0lpss11i_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:01:15
channel dsk1: starting incremental level 0 datafile backup set
channel dsk1: specifying datafile(s) in backup set
input datafile file number=00008 name=+DATA/CDB/0B69FF6895963F6EE05328E7E7C06EFD/DATAFILE/system.273.867680497
input datafile file number=00014 name=+DATA/CDB/0B69FF6895963F6EE05328E7E7C06EFD/DATAFILE/users.287.868553039
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk2: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0mpss11j_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk2: backup set complete, elapsed time: 00:01:15
channel dsk2: starting incremental level 0 datafile backup set
channel dsk2: specifying datafile(s) in backup set
input datafile file number=00005 name=+DATA/CDB/FD9AC20F64D244D7E043B6A9E80A2F2F/DATAFILE/system.270.867679599
channel dsk2: starting piece 1 at 16-JAN-15
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0npss13u_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:00:35
channel dsk2: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/ora_0opss13u_1_1.bak tag=TAG20150116T113640 comment=NONE
channel dsk2: backup set complete, elapsed time: 00:00:35
Finished backup at 16-JAN-15

Starting backup at 16-JAN-15
current log archived
channel dsk1: starting archived log backup set
channel dsk1: specifying archived log(s) in backup set
input archived log thread=1 sequence=38 RECID=14 STAMP=869069711
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk2: starting archived log backup set
channel dsk2: specifying archived log(s) in backup set
input archived log thread=1 sequence=39 RECID=15 STAMP=869069712
input archived log thread=1 sequence=40 RECID=16 STAMP=869138567
channel dsk2: starting piece 1 at 16-JAN-15
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/arc_0ppss158_1_1.bak tag=TAG20150116T114023 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:00:03
channel dsk1: deleting archived log(s)
archived log file name=+DATA/CDB/ARCHIVELOG/2015_01_15/thread_1_seq_38.316.869069709 RECID=14 STAMP=869069711
channel dsk1: starting archived log backup set
channel dsk1: specifying archived log(s) in backup set
input archived log thread=1 sequence=41 RECID=17 STAMP=869139622
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk2: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/arc_0qpss158_1_1.bak tag=TAG20150116T114023 comment=NONE
channel dsk2: backup set complete, elapsed time: 00:00:04
channel dsk2: deleting archived log(s)
archived log file name=+DATA/CDB/ARCHIVELOG/2015_01_15/thread_1_seq_39.315.869069711 RECID=15 STAMP=869069712
archived log file name=+DATA/CDB/ARCHIVELOG/2015_01_16/thread_1_seq_40.314.869138565 RECID=16 STAMP=869138567
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/arc_0rpss15c_1_1.bak tag=TAG20150116T114023 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:00:01
channel dsk1: deleting archived log(s)
archived log file name=+DATA/CDB/ARCHIVELOG/2015_01_16/thread_1_seq_41.312.869139623 RECID=17 STAMP=869139622
Finished backup at 16-JAN-15

Starting Control File and SPFILE Autobackup at 16-JAN-15
piece handle=+DATA/CDB/AUTOBACKUP/2015_01_16/s_869139629.312.869139633 comment=NONE
Finished Control File and SPFILE Autobackup at 16-JAN-15

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           7      15-JAN-15
  Backup Piece       7      15-JAN-15          +DATA/CDB/AUTOBACKUP/2015_01_15/s_869064607.306.869064611
Backup Set           8      15-JAN-15
  Backup Piece       8      15-JAN-15          /u01/backup/ora_0bpsprnu_1_1.bak
Backup Set           9      15-JAN-15
  Backup Piece       9      15-JAN-15          /u01/backup/ora_0cpspro6_1_1.bak
Backup Set           10     15-JAN-15
  Backup Piece       10     15-JAN-15          /u01/backup/ora_0dpsprsp_1_1.bak
Backup Set           11     15-JAN-15
  Backup Piece       11     15-JAN-15          /u01/backup/ora_0epsps1v_1_1.bak
Backup Set           12     15-JAN-15
  Backup Piece       12     15-JAN-15          /u01/backup/ora_0fpsps5a_1_1.bak
Backup Set           13     15-JAN-15
  Backup Piece       13     15-JAN-15          +DATA/CDB/AUTOBACKUP/2015_01_15/s_869068971.313.869068975
Backup Set           14     15-JAN-15
  Backup Piece       14     15-JAN-15          /u01/backup/arch0hpsps8e_1_1.bak
Backup Set           15     15-JAN-15
  Backup Piece       15     15-JAN-15          +DATA/CDB/AUTOBACKUP/2015_01_15/s_869069087.317.869069089
Backup Set           23     16-JAN-15
  Backup Piece       23     16-JAN-15          /u01/backup/arc_0ppss158_1_1.bak
Backup Set           22     16-JAN-15
  Backup Piece       22     16-JAN-15          /u01/backup/arc_0qpss158_1_1.bak
deleted backup piece
backup piece handle=+DATA/CDB/AUTOBACKUP/2015_01_15/s_869064607.306.869064611 RECID=7 STAMP=869064609
deleted backup piece
backup piece handle=+DATA/CDB/AUTOBACKUP/2015_01_15/s_869068971.313.869068975 RECID=13 STAMP=869068974
deleted backup piece
backup piece handle=+DATA/CDB/AUTOBACKUP/2015_01_15/s_869069087.317.869069089 RECID=15 STAMP=869069089
deleted backup piece
backup piece handle=/u01/backup/arc_0ppss158_1_1.bak RECID=23 STAMP=869139624
deleted backup piece
backup piece handle=/u01/backup/arc_0qpss158_1_1.bak RECID=22 STAMP=869139624
Deleted 5 objects

crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0kpss0u9_1_1.bak RECID=16 STAMP=869139404
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0jpss0u9_1_1.bak RECID=17 STAMP=869139404
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0lpss11i_1_1.bak RECID=18 STAMP=869139507
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0mpss11j_1_1.bak RECID=19 STAMP=869139507
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0opss13u_1_1.bak RECID=20 STAMP=869139582
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/ora_0npss13u_1_1.bak RECID=21 STAMP=869139582
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/backup/arc_0rpss15c_1_1.bak RECID=24 STAMP=869139628
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=+DATA/CDB/AUTOBACKUP/2015_01_16/s_869139629.312.869139633 RECID=25 STAMP=869139632
Crosschecked 8 objects

crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_0bpsprnu_1_1.bak RECID=8 STAMP=869068542
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_0cpspro6_1_1.bak RECID=9 STAMP=869068550
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_0dpsprsp_1_1.bak RECID=10 STAMP=869068699
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_0epsps1v_1_1.bak RECID=11 STAMP=869068863
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/ora_0fpsps5a_1_1.bak RECID=12 STAMP=869068970
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/backup/arch0hpsps8e_1_1.bak RECID=14 STAMP=869069071
Crosschecked 6 objects


deleted backup piece
backup piece handle=/u01/backup/ora_0bpsprnu_1_1.bak RECID=8 STAMP=869068542
deleted backup piece
backup piece handle=/u01/backup/ora_0cpspro6_1_1.bak RECID=9 STAMP=869068550
deleted backup piece
backup piece handle=/u01/backup/ora_0dpsprsp_1_1.bak RECID=10 STAMP=869068699
deleted backup piece
backup piece handle=/u01/backup/ora_0epsps1v_1_1.bak RECID=11 STAMP=869068863
deleted backup piece
backup piece handle=/u01/backup/ora_0fpsps5a_1_1.bak RECID=12 STAMP=869068970
deleted backup piece
backup piece handle=/u01/backup/arch0hpsps8e_1_1.bak RECID=14 STAMP=869069071
Deleted 6 EXPIRED objects


Starting backup at 16-JAN-15
channel dsk1: starting full datafile backup set
channel dsk1: specifying datafile(s) in backup set
including current control file in backup set
channel dsk1: starting piece 1 at 16-JAN-15
channel dsk1: finished piece 1 at 16-JAN-15
piece handle=/u01/backup/control_0tpss15r_1_1.bak tag=TAG20150116T114043 comment=NONE
channel dsk1: backup set complete, elapsed time: 00:00:03
Finished backup at 16-JAN-15

Starting Control File and SPFILE Autobackup at 16-JAN-15
piece handle=+DATA/CDB/AUTOBACKUP/2015_01_16/s_869139650.317.869139653 comment=NONE
Finished Control File and SPFILE Autobackup at 16-JAN-15
released channel: dsk1
released channel: dsk2

Recovery Manager complete.


No comments:

Popular Posts - All Times