RMAN Script Example


/home/oracle/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs
export BASHDP='BASHRC'
#PATH=$PATH:$HOME/bin

#export PATH
umask 022
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db1
ORACLE_SID=itcsyariah2
LD_LIBRARY_PATH=$ORACLE_HOME/lib
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID LD_LIBRARY_PATH PATH

/u01/app/oracle/backups/scrips/conf/bck.cfg

ORACLE_BASE=/u01/app/oracle

# how many days we want to keep backups on disk before RMAN deletes them
REDUNDANCY=2

# enable/disable automatic backup of spfile and controlfile
CONTROLFILE_AUTOBACKUP="ON"

# string with the destination of the automatic backup of the spfile and controlfile
CONTROLFILE_AUTOBACKUP_FORMAT="$ORACLE_BASE/backups/controlspfile/%F"

# Define parallelism degree by an integer (only usable on Enterprise Edition),
PARALLELISM=2
# and if the backupset is going to be compressed.
BACKUPSET_TYPE="COMPRESSED BACKUPSET"

# Set the destination of the snapshot control file to be kept on the backups.
SNAPSHOT_CONTROLFILE="$ORACLE_BASE/backups/controlspfile/snapcf_itcsyariah2.f"

DATAFILES_DEST="$ORACLE_BASE/backups/datafiles/%d_%T_s%s_s%p"
ARCHIVELOGS_DEST="$ORACLE_BASE/backups/archivelogs/%d_%T_s%s_s%p"

/u01/app/oracle/backups/scrips/bck.sh

#!/bin/bash

source ~/.bash_profile # $ORACLE_HOME and $ORACLE_SID should be exported here

source $ORACLE_BASE/backups/scripts/conf/bck.cfg

usage() {
echo `basename $0`: ERROR: $* 1>&2
echo usage: `basename $0` '[-[a(rchive log only) f(full)]]' 1>&2
exit 1
}

case "$1" in
-a) BACKUP_TYPE="archivelog all format '$ARCHIVELOGS_DEST' delete input";;
-f) BACKUP_TYPE="database plus archivelog";;
*) usage ;;
esac

rman target / nocatalog <<EOF
# how many days we want to keep backups on disk before RMAN deletes them
CONFIGURE RETENTION POLICY TO REDUNDANCY $REDUNDANCY;

# enable/disable automatic backup of spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP $CONTROLFILE_AUTOBACKUP;

# string with the destination of the automatic backup of the spfile and controlfile
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$CONTROLFILE_AUTOBACKUP_FORMAT';

# Define parallelism degree by an integer (only usable on Enterprise Edition), and if the backupset is going to be compressed.
CONFIGURE DEVICE TYPE DISK PARALLELISM $PARALLELISM BACKUP TYPE TO $BACKUPSET_TYPE;

# Set the destination of the snapshot control file to be kept on the backups.
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '$SNAPSHOT_CONTROLFILE';

backup $BACKUP_TYPE;
exit;
EOF

exit

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: