Total Pageviews

Monday, June 12, 2017

How To Schedule RMAN Full Backup Job


CHECK THE EXISTING BACKUP ON SERVER:

[oracle@ashwanik]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 12 20:02:29 2017

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

connected to target database: ORACLE (DBID=1758901232)

RMAN> list backup;

using target database control file instead of recovery catalog
specification does not match any backup in the repository

As You can see above  I don’t have any existing backup

Lets schedule the FULL backup at daily at 20:15 using cronjob. Backup script resides at /home/oracle/RMANBACKUP_SCRIPTS/RMAN_FULL.sh.

[oracle@ashwanik ~]$ crontab –e

Press i for insert than paste the below line over there and quit from there using  key Esc_+ESC :wq!


15 20 * * * /home/oracle/RMANBACKUP_SCRIPTS/RMAN_FULL.sh > /home/oracle/RMANBACKUP_SCRIPTS/LOG_FULL_BKP/ORACLE_RMAN_FULL_backup_`date +\%d-\%b-\%Y_\%H_\%M_\%S`.log

[oracle@ashwanik]$ cat /home/oracle/RMANBACKUP_SCRIPTS/RMAN_FULL.sh
#RMAN Full backup Scripts
#!/bin/ksh
ORACLE_HOSTNAME=add your hostname here; export ORACLE_HOSTNAME
ORACLE_UNQNAME=oracle; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=oracle; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
mkdir /home/oracle/TEST_2016/ORACLE_"$(date +"%d-%m-%Y")"
test=/home/oracle/TEST_2016/ORACLE_"$(date +"%d-%m-%Y")"
rman target=/ << EOF
RUN {
  ALLOCATE CHANNEL ch1 TYPE
    DISK FORMAT '$test/%d_DB_%u_%s_%p';
  BACKUP DATABASE PLUS ARCHIVELOG;
  DELETE FORCE NOPROMPT EXPIRED BACKUP DEVICE TYPE DISK;
  DELETE FORCE NOPROMPT OBSOLETE;
  RELEASE CHANNEL ch1;
}
EXIT;
EOF

Now Lets check Backup triggered or not.

[oracle@ashwanik ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 12 20:15:37 2017

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

connected to target database: ORACLE (DBID=1758901232)

RMAN> list backup;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8741    51.50K     DISK        00:00:00     12-JUN-17
        BP Key: 8741   Status: AVAILABLE  Compressed: YES  Tag: TAG20170612T203003
        Piece Name: /home/oracle/TEST_2016/ORACLE_12-06-2017/ORACLE_DB_95s6krqb_11557_1

  List of Archived Logs in backup set 8741
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    6629    53809556   12-JUN-17 53809708   12-JUN-17
  1    6630    53809708   12-JUN-17 53809928   12-JUN-17

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
8742    52.00K     DISK        00:00:00     12-JUN-17
        BP Key: 8742   Status: AVAILABLE  Compressed: YES  Tag: TAG20170612T203003
        Piece Name: /home/oracle/TEST_2016/ORACLE_12-06-2017/ORACLE_ARCHIVE_96s6krqb_11558_1

  List of Archived Logs in backup set 8742
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    6629    53809556   12-JUN-17 53809708   12-JUN-17
  1    6630    53809708   12-JUN-17 53809928   12-JUN-17
  1    6631    53809928   12-JUN-17 53809932   12-JUN-17

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8743    Full    11.80M     DISK        00:00:00     12-JUN-17
        BP Key: 8743   Status: AVAILABLE  Compressed: NO  Tag: TAG20170612T203004
        Piece Name: /u01/app/oracle/flash_recovery_area/ORACLE/db_recovery/ORACLE/autobackup/2017_06_12/o1_mf_s_946499404_dmxc3np4_.bkp
  SPFILE Included: Modification time: 18-FEB-17
  SPFILE db_unique_name: ORACLE
  Control File Included: Ckp SCN: 53809948     Ckp time: 12-JUN-17

You can see backup triggered today automatically at 8:15 PM

Also Check the log at location: /home/oracle/RMANBACKUP_SCRIPTS/LOG_FULL_BKP

[oracle@ashwanik ~]$ cd /home/oracle/RMANBACKUP_SCRIPTS/LOG_FULL_BKP
[oracle@ashwanik LOG_FULL_BKP]$ ls -lrth
total 4.0K
-rw-r--r-- 1 oracle oinstall 3.1K Jun 12 20:15 ORACLE_RMAN_FULL_backup_12-Jun-2017_20_30_01.log


[oracle@ashwanik LOG_FULL_BKP]$ cat ORACLE_RMAN_FULL_backup_12-Jun-2017_20_30_01.log

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Jun 12 20:30:01 2017

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

connected to target database: ORACLE (DBID=1758901232)

RMAN> 2> 3> 4> 5> 6> 7> 8>
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=136 device type=DISK


Starting backup at 12-JUN-17
current log archived
channel ch1: starting compressed archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=6629 RECID=6362 STAMP=946499163
input archived log thread=1 sequence=6630 RECID=6363 STAMP=946499403
channel ch1: starting piece 1 at 12-JUN-17
channel ch1: finished piece 1 at 12-JUN-17
piece handle=/home/oracle/TEST_2016/ORACLE_12-06-2017/ORACLE_DB_95s6krqb_11557_1 tag=TAG20170612T203003 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 12-JUN-17

Starting backup at 12-JUN-17
channel ch1: starting compressed full datafile backup set
channel ch1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/oracle/sysaux01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/oracle/system01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/oracle/TS_16K.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/oracle/undotbs01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/oracle/TS_16K_1.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/oracle/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/oracle/users01.dbf
input datafile file number=00006 name=/u01/app/oracle/oradata/oracle/test01.dbf
input datafile file number=00007 name=/u01/datafile/test2.dbf
channel ch1: starting piece 1 at 12-JUN-17

NOTE: Create the Directories for residing backup scripts and log accordingly and should have proper permissions.