One, incremental backup script
Level 0 Backup script: Red section directory for custom backup files
Copy Code code as follows:
#script.: backupfull.sh
#creater: Xyh
#date: 2014-03-08
#desc: Backup full database datafile in archive with Rman
#connect Database
Export Oracle_base=/u01/app/oracle
Export ORACLE_SID=ORCL
Export Oracle_home=/u01/app/oracle/product/10.2.0/db_1
Export path= $ORACLE _home/bin: $PATH
Rman target/<< Eof_rman
run{
Allocate channel C1 type disk;
Backup incremental Level 0 tag ' db0 ' format
'/home/oracle/rmanbackup/db0_%d_%t_%s ' database include current controlfile;
SQL ' alter system archive log current ';
Backup filesperset 5 format '/home/oracle/rmanbackup/cf0_%d_%t_%s ' archivelog all delete input;
#filesperset 5 indicates that the backup set contains up to 5 files
Delete NoPrompt obsolete;
Release channel C1;
}
# End
Level 1 Backup Script
Copy Code code as follows:
#script.: I ncrl.sh
#creater: Xyh
#date: 2014-03-08
#desc: Backup full database datafile in archive with Rman
#connect Database
Export Oracle_base=/u01/app/oracle
Export ORACLE_SID=ORCL
Export Oracle_home=/u01/app/oracle/product/10.2.0/db_1
Export path= $ORACLE _home/bin: $PATH
Rman target/<< Eof_rman
run{
Allocate channel C1 type disk;
Backup incremental Level 1 tag ' DB1 ' format
'/home/oracle/rmanbackup/db1_%d_%t_%s ' database include current controlfile;
SQL ' alter system archive log current ';
Backup filesperset 5 format '/home/oracle/rmanbackup/cf1_%d_%t_%s ' archivelog all delete input;
#filesperset 5 indicates that the backup set contains up to 5 files
Delete NoPrompt obsolete;
Release channel C1;
}
#end
Second, the use of Linux crontab settings to automate the backup
Copy Code code as follows:
When you press ENTER, you can enter the following as the VI editor
Copy Code code as follows:
0 1 * * 0/home/oracle/backupfull.sh >>/home/oracle/backupfull.log
0 1 * * 3/home/oracle/backupfull.sh >>/home/oracle/backupfull.log
1 * * 1-2/home/oracle/incrl.sh >>/home/oracle/incr.log
1 * * 4-6/home/oracle/incrl.sh >>/home/oracle/incr.log
View crontab content: Crontab-l
Note: The above means to write the whole library backup log to the/home/oracle/backupfull.log file, while the incremental backup log is written to the/home/oracle/incr.log
Sunday and Wednesday 1:00 perform 0-level full-Library backup, 周一、二, four, five or six 1:30 incremental backup