Before everything, create a directory rman 

  mkdir -p  /home/oracle/rman
 

1) create the script for backup policy
[oracle@station78 rman]$ cat backup.sh
#!/bin/sh
sub_daily_level1(){
#!/bin/sh
#Daily Level0 Backup O11g(11.2.0.3)
#preview modify the parameter db_recovery_file_dest to a proper value.
 
#option: change tracking
# alter database enable block change tracking using file '/u01/app/oracle/oradata/rman_inc.trk';
# alter database disable block change tracking;
# v$block_change_tracking(status)
 
#format '%s %T %p %t'
# %s the number of backupset
# %t timestamp of backupset
set -x
LOG_DIR='/home/oracle/rman'
DATE=`date +%Y%m%d`
rman target / trace $LOG_DIR/daily_`date +%Y-%m-%d_%H:%M:%S`.log append <<EOF
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 90 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%s_%F_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 5 BACKUP TYPE TO BACKUPSET;
 
crosscheck backupset;
report obsolete;
delete force noprompt obsolete;
 
backup incremental level 1 tag "FULL_DB_LEVEL1" database include current controlfile;
 
release channel;
EOF
}
 
sub_weekly_level0(){
#!/bin/sh
#Weekly Level0 Backup O11g(11.2.0.3)
 
#command
# restore archivelog all preview recall;
# restore archivelog from scn xxx;
# delete expired archivelog all;
# backup archivelog all;
 
#format '%s %T %p %t'
# %s the number of backupset
# %t timestamp of backupset
set -x
LOG_DIR='/home/oracle/rman'
DATE=`date +%H_%M_%S`
rman target / trace $LOG_DIR/weekly_`date +%Y-%m-%d_%H:%M:%S`.log append <<EOF
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 90 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%s_%F_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 5 BACKUP TYPE TO BACKUPSET;
 
crosscheck backupset;
crosscheck archivelog all;
report obsolete;
delete force noprompt obsolete;
 
backup tag "CTL$DATE"  current controlfile;
backup as compressed backupset incremental level 0 tag "FULL_DB_LEVEL0" database plus archivelog delete input;
 
release channel;
EOF
}
 
case $1 in
daily) sub_daily_level1
;;
weekly) sub_weekly_level0
;;
*) echo "
Please input [daily|weekly]
 
"
;;
esac



2) Use crontab  -e to create crontab mission.
[oracle@station78 rman]$ crontab -l
10 1 * * 0 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh weekly
10 1 * * 1 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily
10 1 * * 2 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily
10 1 * * 3 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily
10 1 * * 4 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily
10 1 * * 5 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily
10 1 * * 6 source /home/oracle/.bash_profile && /home/oracle/rman/backup.sh daily

 

Windows

@@@Part 1
1) edit win_backup_daily.bat
rem run rman
set ORACLE_SID=testdb
rman cmdfile=C:\win_backup_daily.txt msglog=c:/orabackup/daily_rman_log__%date:~0,4%_%date:~5,2%_%date:~8,2%.log append

2) edit win_backup_daily.txt
connect target;

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%s_%F_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
 
crosscheck backupset;
crosscheck archivelog all;
report obsolete;
delete force noprompt obsolete;
 
backup current controlfile;

run {
backup
as compressed backupset
incremental level 1
tag "FULL_DB_LEVEL1"
database format  'c:/orabackup/full_%d_%T_%s';
}

release channel;

@@@part2
1) editwin_backup_weekly.bat
rem run rman
set ORACLE_SID=testdb
rman cmdfile=C:\win_backup_weekly.txt log=c:/orabackup/weekly_rman_log__%date:~0,4%_%date:~5,2%_%date:~8,2%.log append

2) edit win_backup_weekly.txt
connect target;

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%s_%F_%t';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
 
crosscheck backupset;
crosscheck archivelog all;
report obsolete;
delete force noprompt obsolete;
 
backup current controlfile;

run {
backup
as compressed backupset
incremental level 0
tag "FULL_DB_LEVEL0"
database format  'c:/orabackup/full_%d_%T_%s'
plus
archivelog format 'c:/orabackup/arch_%d_%T_%s'
delete all input;
}

release channel;