Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1852433
  • 博文数量: 524
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2483
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-25 18:36
个人简介

打杂

文章分类

全部博文(524)

文章存档

2022年(3)

2021年(9)

2019年(1)

2018年(32)

2017年(11)

2016年(152)

2015年(198)

2014年(118)

分类: Oracle

2014-11-21 11:41:59

[oracle@oracle1 script]$ ll
total 40
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back0.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back1.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back2.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back3.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back4.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back5.sh
-rwxrwxrwx 1 oracle oinstall 294 Dec 25  2013 back6.sh
-rwxrwxrwx 1 oracle oinstall 552 Mar  7  2014 bakl0
-rwxrwxrwx 1 oracle oinstall 502 Mar  7  2014 bakl1
-rwxrwxrwx 1 oracle oinstall 503 Mar  7  2014 bakl2
[oracle@oracle1 script]$ cat back0.sh
#!/bin/sh
export ORACLE_BASE=/u01
export ORACLE_HOME=$ORACLE_BASE/oracle/product/10.2.0/db_1
export ORACLE_SID=prod1
export PATH=$ORACLE_HOME/bin:$PATH
export rman=/u01/oracle/product/10.2.0/db_1/bin/rman
$rman target /  cmdfile=/u01/rmanbak/script/bakl0 msglog=/u01/rmanbak/bakl0.log  <

oracle备份顺序:先备数据文件,然后是归档日志,最后才是控制文件,最后是sfplie文件。
零级增量备份
[oracle@oracle1 script]$ cat bakl0
run {
allocate channel a1 type disk;
allocate channel a2 type disk;
backup incremental level 0 database format '/u01/rmanbak/level0_%d_%s_%T.bak' tag='level 0';
sql 'alter system archive log current';
backup archivelog all format '/u01/rmanbak/log_%d_%s_%T.bak' delete all input;
backup current controlfile tag='bak_ctlfile' format='/u01/rmanbak/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u01/rmanbak/ORCL_spfile_%U_%T';
release channel a2;
release channel a1;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}
一级增量备份
[oracle@oracle1 script]$ cat bakl1
run {
allocate channel d1 type disk;
backup incremental level 1 format '/u01/rmanbak/level1_%d_%s_%T.bak' tag = 'level 1' database;
sql 'alter system archive log current';
backup archivelog all format '/u01/rmanbak/log_%d_%s_%T.bak' delete all input;
backup current controlfile tag='bak_ctlfile' format='/u01/rmanbak/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u01/rmanbak/ORCL_spfile_%U_%T';
release channel d1;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}

二级增量备份
[oracle@oracle1 script]$ cat bakl2
run {
allocate channel c1 type disk;
backup incremental level 2 format '/u01/rmanbak/level2_%d_%s_%T.bak' tag = 'level 2' database;
sql 'alter system archive log current';
backup archivelog all format '/u01/rmanbak/log_%d_%s_%T.bak' delete all input;
backup current controlfile tag='bak_ctlfile' format='/u01/rmanbak/ctl_file_%U_%T';
backup spfile tag='spfile' format='/u01/rmanbak/ORCL_spfile_%U_%T';
release channel c1;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
}

oracle用户下定时执行任务
[oracle@oracle1 script]$ crontab -l
10 23 * * 0 /u01/rmanbak/script/back0.sh
11 23 * * 1 /u01/rmanbak/script/back1.sh
12 23 * * 2 /u01/rmanbak/script/back2.sh
13 23 * * 3 /u01/rmanbak/script/back3.sh
14 23 * * 4 /u01/rmanbak/script/back4.sh
15 23 * * 5 /u01/rmanbak/script/back5.sh
16 23 * * 6 /u01/rmanbak/script/back6.sh
50 23 * * * /u01/backup/backup.sh

下面这个是每天逻辑导出oracle数据库
[oracle@oracle1 script]$ cat /u01/backup/backup.sh
#!/bin/bash
export ORACLE_HOME=/u01/oracle/product/10.2.0/db_1
export ORACLE_SID=prod1
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK 
rq=`date +%y%m%d_%H`
$ORACLE_HOME/bin/exp datum/giapdata owner=datum file=/u01/backup/exp_${rq}.dmp log=/u01/backup/exp_${rq}.log
没有删除功能。

 

阅读(1282) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~