|
Creating
the script for the On-line backup using RMAN
Here
is the content of /home/oracle/Desktop/Backup_rman/scripts/hot_database_backup_disk.sh
:
#/usr/bin/ksh
export ORACLE_HOME=/DB1
export ORACLE_SID=db1
RMAN_LOG_FILE=/home/oracle/Desktop/Backup_rman/log/hot_database_backup.`date
+%y%m%d%H%M`.out
# -----------------------------------------------------------------
# Initialize the log file.
# -----------------------------------------------------------------
echo>> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
echo Script $0>> $RMAN_LOG_FILE
echo ==== started on `date` ====>> $RMAN_LOG_FILE
echo>> $RMAN_LOG_FILE
ORACLE_USER=oracle
TARGET_CONNECT_STR=sys/s
RMAN=$ORACLE_HOME/bin/rman
BACKUP_TYPE="INCREMENTAL LEVEL 0"
#
---------------------------------------------------------------------------
# Print out the value of the variables set by this script.
#
---------------------------------------------------------------------------
echo>> $RMAN_LOG_FILE
echo "RMAN: $RMAN">> $RMAN_LOG_FILE
echo "ORACLE_SID: $ORACLE_SID">> $RMAN_LOG_FILE
echo "ORACLE_USER: $ORACLE_USER">> $RMAN_LOG_FILE
echo "ORACLE_HOME: $ORACLE_HOME">> $RMAN_LOG_FILE
echo "BACKUP_TYPE: $BACKUP_TYPE">> $RMAN_LOG_FILE
#
---------------------------------------------------------------------------
echo >> $RMAN_LOG_FILE
CMD_STR=""
$RMAN target $TARGET_CONNECT_STR catalog rman/r@dbr << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE disk ;
ALLOCATE CHANNEL ch01 TYPE disk ;
ALLOCATE CHANNEL ch02 TYPE disk ;
ALLOCATE CHANNEL ch03 TYPE disk ;
BACKUP
$BACKUP_TYPE
SKIP INACCESSIBLE
TAG hot_db_bk_level0
FILESPERSET 5
# recommended format
FORMAT '/home/oracle/Desktop/Backup_rman/backup/bk_%s_%p_%t'
DATABASE;
sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
RELEASE CHANNEL ch03;
# backup all archive logs
ALLOCATE CHANNEL ch00 TYPE disk;
ALLOCATE CHANNEL ch01 TYPE disk;
BACKUP
SKIP INACCESSIBLE
filesperset 20
FORMAT '/home/oracle/Desktop/Backup_rman/backup/al_%s_%p_%t'
ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
ALLOCATE CHANNEL ch00 TYPE disk;
BACKUP
# recommended format
FORMAT '/home/oracle/Desktop/Backup_rman/backup/cntrl_%s_%p_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
EOF
NOTE:
The database must be in archivelog mode.
Running
the shell script to start the backup

Here
are the messages which appears during the online backup:
[oracle@PROD
scripts]$ ./hot_database_backup_disk.sh
Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 25 22:38:21
2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: DB1 (DBID=1244100437)
connected to recovery catalog database
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11>
12> 13> 14> 15> 16> 17> 18> 19> 20> 21>
22> 23> 24> 25> 26> 27> 28> 29> 30> 31>
32> 33> 34> 35> 36> 37>
allocated channel: ch00
channel ch00: sid=159 devtype=DISK
allocated channel: ch01
channel ch01: sid=152 devtype=DISK
allocated channel: ch02
channel ch02: sid=144 devtype=DISK
allocated channel: ch03
channel ch03: sid=148 devtype=DISK
Starting backup at 25-MAR-08
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00001 name=/DB1/oradata/db1/system01.dbf
channel ch00: starting piece 1 at 25-MAR-08
channel ch01: starting incremental level 0 datafile backupset
channel ch01: specifying datafile(s) in backupset
input datafile fno=00003 name=/DB1/oradata/db1/sysaux01.dbf
input datafile fno=00004 name=/DB1/oradata/db1/users01.dbf
channel ch01: starting piece 1 at 25-MAR-08
channel ch02: starting incremental level 0 datafile backupset
channel ch02: specifying datafile(s) in backupset
input datafile fno=00005 name=/DB1/oradata/db1/example01.dbf
input datafile fno=00002 name=/DB1/oradata/db1/undotbs01.dbf
channel ch02: starting piece 1 at 25-MAR-08
channel ch03: starting incremental level 0 datafile backupset
channel ch03: specifying datafile(s) in backupset
including current control file in backupset
channel ch03: starting piece 1 at 25-MAR-08
channel ch03: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_23_1_650327905
tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch03: backup set complete, elapsed time: 00:00:08
channel ch03: starting incremental level 0 datafile backupset
channel ch03: specifying datafile(s) in backupset
channel ch02: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_22_1_650327905
tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch02: backup set complete, elapsed time: 00:00:08
including current SPFILE in backupset
channel ch03: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_20_1_650327905
tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:15
channel ch01: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_21_1_650327905
tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:15
channel ch03: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/bk_24_1_650327913
tag=HOT_DB_BK_LEVEL0 comment=NONE
channel ch03: backup set complete, elapsed time: 00:00:07
Finished backup at 25-MAR-08
sql statement: alter system archive log current
released channel: ch00
released channel: ch01
released channel: ch02
released channel: ch03
allocated channel: ch00
channel ch00: sid=159 devtype=DISK
allocated channel: ch01
channel ch01: sid=152 devtype=DISK
Starting backup at 25-MAR-08
current log archived
channel ch00: starting archive log backupset
channel ch00: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=5 stamp=650327923
channel ch00: starting piece 1 at 25-MAR-08
channel ch01: starting archive log backupset
channel ch01: specifying archive log(s) in backup set
input archive log thread=1 sequence=2 recid=6 stamp=650327924
channel ch01: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/al_25_1_650327925
tag=TAG20080325T223845 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:02
channel ch00: deleting archive log(s)
archive log filename=/DB1/flash_recovery_area/DB1/archivelog/2008_03_25/o1_mf_1_1_3ymb92xz_.arc
recid=5 stamp=650327923
channel ch01: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/al_26_1_650327925
tag=TAG20080325T223845 comment=NONE
channel ch01: backup set complete, elapsed time: 00:00:03
channel ch01: deleting archive log(s)
archive log filename=/DB1/flash_recovery_area/DB1/archivelog/2008_03_25/o1_mf_1_2_3ymb94lz_.arc
recid=6 stamp=650327924
Finished backup at 25-MAR-08
released channel: ch00
released channel: ch01
allocated channel: ch00
channel ch00: sid=159 devtype=DISK
Starting backup at 25-MAR-08
channel ch00: starting full datafile backupset
channel ch00: specifying datafile(s) in backupset
including current control file in backupset
channel ch00: starting piece 1 at 25-MAR-08
channel ch00: finished piece 1 at 25-MAR-08
piece handle=/home/oracle/Desktop/Backup_rman/backup/cntrl_27_1_650327930
tag=TAG20080325T223850 comment=NONE
channel ch00: backup set complete, elapsed time: 00:00:01
Finished backup at 25-MAR-08
released channel: ch00
RMAN>
Recovery Manager complete.
[oracle@PROD scripts]$
More information
about this subject (
FULL online database backup using RMAN Recovery Catalog ) you can get from
www.in-oracle.com
|