Oracle RMAN基础应用
RMAN备份必须在Oracle 的归档模式下才能进行
查看数据库是否处于归档模式
archive log list
更改数据库的归档模式
shutdown immediate
startup mount
alter database archivelog;
alter database open;
查看RMAN的备份环境
rman target/
show all;
启动控制文件自动备份
configure controlfile autobackup on;
show controlfile autobackup;
全库备份
backup database;
查看备份信息
list backup;
list backup summary;
编写备份脚本
0级全库备份脚本
vi BackupFull.sh
#Date 2014/4/6
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin:
rman target/ <<EOF_RMAN
run{
allocate channel c1 type disk;
backup incremental level 0 tag 'db0' format 'u01/app/oracle/Backup/db0_%d_%T_%s' database
include current controlfile;
delete nopromp obsolete;
release channel c1;
}
#end
1级增量备份
vi Incr1.sh
#Date 2014/4/6
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin:
rman target/ <<EOF_RMAN
run{
allocate channel c1 type disk;
backup incremental level 1 tag 'db1' format 'u01/app/oracle/Backup/db0_%d_%T_%s' database
include current controlfile;
delete nopromp obsolete;
release channel c1;
}
#end
chmod 755 BackupFull.sh
chmod 755 Incr1.sh
自动执行备份脚本
crontab –e
0 1 * * 0 /u01/app/oracle/Backup/BackupFull.sh
>>/u01/app/oracle/Backup/BackupFull.log
0 1 * * 3 /u01/app/oracle/Backup/BackupFull.sh
>>/u01/app/oracle/Backup/BackupFull.log
30 1 * * 1-2 /u01/app/oracle/Backup/Incr1.sh
>>/u01/app/oracle/Backup/Incr1.log
30 1 * * 4-6 /u01/app/oracle/Backup/Incr1.sh
>>/u01/app/oracle/Backup/Incr1.log
Ps:周日和周三凌晨1点执行0级全库备份,其余天数1:30执行1级增量备份
查看crontab
crontab –l
推荐阅读: