Rman> CONFIGURE RETENTION POLICY to redundancy 2;
Rman> CONFIGURE RETENTION POLICY to RECOVERY WINDOW of;
Enable control file automatic backup and backup storage location configuration
Rman> Configure Controlfile autobackup on;
View configuration information
Rman> Show All;
-------------------------------------------------
--Create Folder
$mkdir/home/oracle/backup
Mkdir/home/oracle/backup/script
Mkdir/home/oracle/backup/log
Mkdir/home/oracle/backup/export
--Backup destination
Mkdir/home/oracle/rman_backup
Create a backup table space
Create tablespace rman_tbs datafile '/u01/app/oracle/oradata/orcl11g/rman_tbs01.dbf '
Size 1024M autoextend on next 50M maxsize 10240M
Extent management local segment space management auto;
Create a backup user
Create user Rman identified by rman default tablespace rman_tbs temporary tablespace temp;
Grant Connect,resource, Recovery_catalog_owner to Rman;
Sql> Grant Unlimited tablespace to Rman;
Sql> Grant SYSDBA to Rman;
Rman Catalog Rman/rman
Create catalog tablespace Rman_tbs;
Connect target sys/[email protected]
Register database;
Report schema;
-------------------------------------------------------
--Pour out rman user data script Exp_rman.par (i.e. back up catalog library)
Userid=rman/rman
File=/home/oracle/backup/export/rman.dmp
Log=/home/oracle/backup/log/rman.log
--Pour out the Rman data shell script exp_rman.sh
#!/bin/bash
CD $HOME
. . bash_profile
CD $HOME/backup/script
Exp Parfile=exp_rman.par
--------------
---Level 0 backup rman script LEVEL0_BACKUP.RCV
Connect catalog Rman/rman
Connect target sys/[email protected]
Run {
Allocate Channel D1 type disk;
Allocate channel D2 type disk;
Backup Incremental Level 0 database format '/home/oracle/rman_backup/level0_%d_%s_%p_%u.bak '
tag= ' Level 0 ' Include current controlfile;
SQL ' alter system archive log current ';
Backup Archivelog All format '/home/oracle/rman_backup/arc_%d_%s_%p_%u.bak ';
Release channel D2;
Release channel D1;
}
Crosscheck backup;
Delete noprompt expired backup;
Delete noprompt obsolete;
Crosscheck Archivelog All;
Delete noprompt Archivelog all completed before ' sysdate-15 ';
Resync Catalog;
--level0_backup.sh of level 0 backup shell script
#!/bin/bash
Backtime= ' date + '%y%m%d%h '
#cd $HOME
. /home/oracle/.bash_profile
CD $HOME/backup/script
Rman CMDFILE=LEVEL0_BACKUP.RCV msglog= $HOME/backup/log/level0_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh
First-level differential incremental backup Rman script LEVEL1_BACKUP.RCV
Connect Catalog Rman/rman
Connect target sys/[email protected]
Run {
Allocate channel D1 type disk;
Backup incremental Level 1 format '/home/oracle/rman_backup/level1_%d_%s_%p_%u.bak ' tag = ' Level 1 ' cumulative database;
SQL ' alter system archive log current ';
Backup Archivelog all format '/home/oracle/rman_backup/log_%d_%s_%p_%u.bak ';
Release channel D1;
}
Crosscheck backup;
Delete noprompt expired backup;
Delete NoPrompt obsolete;
Crosscheck Archivelog All;
Delete noprompt Archivelog all completed before ' sysdate-15 ';
Resync Catalog;
--one-level differential incremental backup shell script level1_backup.sh
#!/bin/bash
Backtime= ' date + '%y%m%d%h '
#cd $HOME
. /home/oracle/.bash_profile
Cd/home/oracle/backup/script
Rman CMDFILE=LEVEL1_BACKUP.RCV msglog= $HOME/backup/log/level1_${backtime}.log
. /home/oracle/backup/script/exp_rman.sh
Execute backup script under Linux schedule
CRONTAB-E-U Oracle
Shell=/bin/bash--The following script executes under bash
Mailto=oracle--The execution log is mailed to Oracle users and can be/var/spool/mail/oracle
5 * * 1 nohup/home/oracle/backup/script/level0_backup.sh >/home/oracle/backup/cron.log 2>&1 &
5 * * 3/home/oracle/backup/script/level1_backup.sh
5 * * 5/home/oracle/backup/script/level1_backup.sh
A week differential backup strategy:
Backing up the target Library and catalog library
Weekly Level 10 full, Wednesday Friday is 1.
Start Backup every 12:5
Oracle Backup Strategy