1. Oracle scheduled task:
Crontab-e
* ***/Home/oracle/workspace/scripts/bk_main.sh>/home/oracle/workspace/log/bk_err.log 2> & 1
2. Main Control Program
/Home/oracle/workspace/scripts/bk_main.sh
#! /Bin/bash
Dat = 'date + '% m''
If ($ dat = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 0
Elif ($ dat % 50 = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 2
Elif ($ dat % 40 = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 2
Elif ($ dat % 30 = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 1
Elif ($ dat % 20 = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 2
Elif ($ dat % 10 = 0 ))
Then
/Home/oracle/workspace/scripts/bk _. sh 2
Fi
3. Detailed backup script description: 'date + '% Y % m % d % k % m' | awk' {print $1 $2} ''is in the yyyymmddhh24mi format of the current time.
/Home/oracle/workspace/scripts/bk _. sh
#! /Bin/bash
# This is a import statement.
PATH = $ PATH: $ HOME/bin
Export PATH
Export ORACLE_SID = dex
Export ORACLE_BASE =/u01/apps/oracle
Export ORACLE_HOME = $ ORACLE_BASE/product/11gr2/db_1
Export PATH = $ ORACLE_HOME/bin: $ PATH
# Use awk to cut the space char
Timst = 'date + '% Y % m % d % k % m' | awk' {print $1 $2 }''
# Use for debug
# Echo $ timst
# Create a directory like 201112140112
Mkdir/u01/backup/DEX/backups/$ timst
# Rman backup scripts
Rman target sys/xiaojun @ dex log =/home/oracle/workspace/log/rmanlog/rman _ $ timst <EOF
Run {
Allocate channel dev1 type disk;
Allocate channel dev2 type disk;
Backup incremental level 1 database format'/u01/backup/DEX/backups/$ timst/bk _ % t _ % s' plus archivelog format'/u01/backup/DEX/backups/ $ timst/arc _ % t _ % s' delete all input;
Crosscheck backup;
Delete noprompt obsolete;
Delete noprompt expired backup;
}
EOF
Do not forget to create a directory.