?
-h 查看帮助信息
[oracle@gc1 ~]$ sh backup.sh -h
The following information teach you how to use this script
backup.sh --full
backup.sh --incr0
backup.sh --incr1
THE is the place where you want to store the backup
After you set the RMAN_HOME , The script will create the following directory:
-- 2015_06_01
|-- archlog --This directory store your archivelog backup
|-- ctlfile --This directory store your controlfile bakcup
|-- data --This directory store your backup
| |-- incr0 --This is your incr0 backupset
-- log --This is your backup log directory
|-- dbbak.log --This log records the backup start and finish time points
|-- incr0_2015-06-01.log --This your backup log records the rman output information
backup.sh --help
Usage:
backup.sh --full
backup.sh --incr0
backup.sh --incr1
backup.sh --help
#!/bin/bash
cmd=$1
script_name=`basename $0`
RMAN_HOME=$2/`date +%Y_%m_%d`
print_usage() {
echo "Usage:"
echo " $script_name --full "
echo " $script_name --incr0 "
echo " $script_name --incr1 "
echo " $script_name --help "
}
print_help() {
echo "The script was written by FAN"
echo "The following information teach you how to use this script"
echo " $script_name --full"
echo " $script_name --incr0 "
echo " $script_name --incr1 "
echo " THE is the place where you want to store the backup"
echo " After you set the RMAN_HOME , The script will create the following directory:"
echo " -- 2015_06_01"
echo " |-- archlog --This directory store your archivelog backup"
echo " |-- ctlfile --This directory store your controlfile bakcup"
echo " |-- data --This directory store your backup"
echo " | |-- incr0 --This is your incr0 backupset"
echo " -- log --This is your backup log directory"
echo " |-- dbbak.log --This log records the backup start and finish time points"
echo " |-- incr0_2015-06-01.log--This your backup log records the rman output information"
echo " $script_name --help"
print_usage
}
full() {
#-----------------------script env-----------------------
local LOGFILE=$RMAN_HOME/$datedir/log/dbbak.log
local LOGDATE=`date +%Y-%m-%d`
local RMANLOG=$RMAN_HOME/$datedir/log/full_${LOGDATE}.log
if [ ! -d ${RMAN_HOME} ];
then mkdir -p $RMAN_HOME
mkdir $RMAN_HOME/archlog
mkdir $RMAN_HOME/ctlfile
mkdir $RMAN_HOME/data
mkdir $RMAN_HOME/log
mkdir $RMAN_HOME/data/full
fi
if [ ! -f ${LOGFILE} ];
then touch ${LOGFILE}
fi
if [ ! -f ${RMANLOG} ];
then touch ${RMANLOG}
fi
#-------------start backup-----------------
echo "-------------------------Rman full backup -------------------------" >> ${LOGFILE}
echo "backup_full start time:" `date +%Y-%m-%d_%H:%M:%S` >> ${LOGFILE}
echo "----------------------Rman Database backup_full ------------"`date +%Y-%m-%d_%H:%M:%S` >${RMANLOG}
$ORACLE_HOME/bin/rman target / <> ${RMANLOG}
run
{
delete noprompt obsolete;
crosscheck archivelog all;
delete noprompt expired archivelog all;
allocate channel c1 type disk MAXPIECESIZE 5g;
allocate channel c2 type disk MAXPIECESIZE 5g;
allocate channel c3 type disk MAXPIECESIZE 5g;
allocate channel c4 type disk MAXPIECESIZE 5g;
allocate channel c5 type disk MAXPIECESIZE 5g;
backup AS COMPRESSED BACKUPSET database tag 'fullbackup' filesperset 3 format '$RMAN_HOME/data/full/db_full_%T_%d_%t_%s_%p.rbck' include current controlfile;
ba