Thursday 5 December 2013

cronjob RMAN Script for Friday Full Backup and all other days incremental Backup

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~cronjob entry~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[oracle@emsleerpt01 oracle/] $ crontab -l
# RMAN Backup
# Full Friday, incremental every other day
#########################################################
21 20 * * 5 /u01/backups/rman/scripts/run_rman weekly.rcv
21 20 * * 0,1,2,3,4,6 /u01/backups/rman/scripts/run_rman daily.rcv

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~run_rman~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[oracle@emsleerpt01 scripts/] $ more run_rman
#!/bin/ksh
. /apps/oracle/.profile
#typeset -L day=$date+%e
cd /u01/backups/rman/scripts
for ORACLE_SID in PV
do
        export ORACLE_SID
        rman target / nocatalog log logfile.log cmdfile $1
        cp logfile.log ../logs/$ORACLE_SID.$day
done

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~daily.rcv~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[oracle@emsleerpt01 scripts/] $ more daily.rcv
# This is a daily cumulative incremental backup
# Ensure a daily one has been done as it will setup the persistent parameters
# in RMAN
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE FILESPERSET 4;
BACKUP ARCHIVELOG ALL;
DELETE OBSOLETE;

LIST BACKUP;
#-end of file-

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~weekly.rcv~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[oracle@emsleerpt01 scripts/] $ more weekly.rcv
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/backups/rman/backupsets/ora_df%t_s%s_s%p';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/backups/rman/backupsets/PV/%F';
# Set the retention policy to a recovery window of 14 days.  This ensures that
# RMAN retains all backups needed to recover the database to any point in time
# in the last 10 days.  You can use the DELETE OBSOLETE command to delete
# backups that are no longer required by the retention policy. To exclude a
# backup from consideration by the policy, you can use KEEP option with the
# BACKUP command.
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
# Enable the autobackup feature to backup the controlfile after each database
# or archivelog backup.
CONFIGURE CONTROLFILE AUTOBACKUP ON;
# Enable the backup optimization feature introduced in 9i to make sure that
# RMAN won't backup an archivelog or datafile if there already exists a backup
# of that file. The FORCE option can be used to override optimization on a
# specific BACKUP command.
CONFIGURE BACKUP OPTIMIZATION ON;

# IMPORTANT: Save the database id displayed in the RMAN output if you are
# operating RMAN backups in nocatalog mode, since it is required during
# disaster recovery.  You will see the database id in output from RMAN on
# connecting to target database like:
#
# connected to target database: PV (DBID=1409605046)
# Use the SHOW ALL command to see the current configuration settings.
# Following scenario assumes that you want to take one full database once a
# week, doing every day incrementals. Backup cycle starts on friday,
# i.e., every friday full backup, and on other days incrementals.

# Section 2.1 - Start script for backup cycle
# -------------------------------------------
# The following commands are run each Friday to start the backup cycle.
# The steps are:
#  - Take an incremental level 0 backup of the database.  A level 0 backup is
#    a complete backup of the entire file which can be used as the basis
#    for a subsequent incremental backup.
#  - Backup all archivelogs that have not already been backed up.
#  - Delete on-disk archivelogs older than seven days.
BACKUP INCREMENTAL LEVEL 0 DATABASE FILESPERSET 4;
BACKUP ARCHIVELOG ALL;
DELETE OBSOLETE;
# If the above backup fails for any reaon, you can use the NOT BACKED UP SINCE
# option on the BACKUP command (9i restartable backup feature) to continue
# from the point of failure.  The small value of FILESPERSET is good for
# restartable backups.  However you should note that smaller FILESPERSET
# produces more backup sets.
# Use the following commands to re-start backups after a failure:
#BACKUP INCREMENTAL LEVEL 0 DATABASE FILESPERSET 4
#   NOT BACKED UP SINCE TIME 'SYSDATE-1';
#BACKUP ARCHIVELOG ALL DELETE ALL INPUT;
#DELETE ARCHIVELOG UNTIL TIME 'SYSDATE-7';
LIST BACKUP;


#-end of file-

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

No comments:

Post a Comment