I. Incremental backup script
Level 0 backup script: The red part is the directory of the custom backup file
Copy codeThe Code is 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 a maximum of five files.
Delete noprompt obsolete;
Release channel c1;
}
# End
Level 1 backup script
Copy codeThe Code is as follows:
# Script.: Incrl. 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 a maximum of five files.
Delete noprompt obsolete;
Release channel c1;
}
# End
Ii. use linux crontab settings to automatically execute backup
Copy codeThe Code is as follows:
Crontab-e
After you press Enter, you can Enter the following content like the vi editor.
Copy codeThe Code is as follows:
0 1 ** 0/home/oracle/BackupFull. sh>/home/oracle/BackupFull. log
0 1 ** 3/home/oracle/BackupFull. sh>/home/oracle/BackupFull. log
30 1 ** 1-2/home/oracle/Incrl. sh>/home/oracle/Incr. log
30 1 ** 4-6/home/oracle/Incrl. sh>/home/oracle/Incr. log
View crontab content: crontab-l
Note: The above indicates writing the full-database backup log to the/home/oracle/BackupFull. log File, while the Incremental backup log is written to/home/oracle/Incr. log.
Perform full-database backup at on Sunday and Wednesday, and Incremental backup at on Monday, 2, 4, 5, and 6.