博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
oracle rman备份脚本学习
阅读量:5839 次
发布时间:2019-06-18

本文共 4544 字,大约阅读时间需要 15 分钟。

hot3.png

无论在什么系统下,运用数据库都是必不可少的。今天我就来跟大家探讨一下oracle rman备份脚本学习。
查询字符集
SQL> select * from nls_database_parameters;
NLS_CHARACTERSET
AL32UTF8  
备份时字符集很重要,不然会出乱码
一、0级备份(全备)红色是要修改的,根据个人的存放位置。
[oracle@oracle122 script]$ cat db_bak0.rman 
run
{
    configure retention policy to recovery window of 8 days;
    configure controlfile autobackup on;
    configure controlfile autobackup format for device type disk to '/home/oracle/rmanbak/%F';
    allocate channel ch1 device type disk format '/home/oracle/rmanbak/inc0_%d_%s_%p_%u_%T';
    backup incremental level 0 tag='level 0' database skip inaccessible filesperset 10 plus archivelog filesperset 20;
    release channel ch1;
}
allocate channel for maintenance device type disk;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
delete noprompt archivelog until time 'sysdate-30';
0级运行脚本
[oracle@oracle122 script]$ cat exec_0_level.sh 
ORACLE_HOSTNAME=oracle122; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbinPATH; export PATH
PATH=$ORACLE_HOME/binPATH; export PATH
export DATE=$(date +%Y_%m_%d)
export NLS_LANG="Simplified Chinese_china".AL32UTF8
/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target sys/sys_admin cmdfile /home/oracle/rmanbak/script/db_bak0.rman log/home/oracle/rmanbak/script/log/rman_$DATE.log append
二、1级备份(增量)
[oracle@oracle122 script]$ cat db_bak1.rman 
run
{
    configure retention policy to recovery window of 8 days;
    configure controlfile autobackup on;
    configure controlfile autobackup format for device type disk to '/home/oracle/rmanbak/%F';
    allocate channel ch1 device type disk format '/home/oracle/rmanbak/inc1_%d_%s_%p_%u_%T';
    backup incremental level 1 tag='level 1' database skip inaccessible filesperset 10 plus archivelog filesperset 20;
    release channel ch1;
}
allocate channel for maintenance device type disk;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
delete noprompt archivelog until time 'sysdate-30';
1级运行脚本
[oracle@oracle122 script]$ cat exec_1_level.sh 
ORACLE_HOSTNAME=oracle122; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbinPATH; export PATH
PATH=$ORACLE_HOME/binPATH; export PATH
export DATE=$(date +%Y_%m_%d)
export NLS_LANG="Simplified Chinese_china".AL32UTF8
/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target sys/sys_admin cmdfile /home/oracle/rmanbak/script/db_bak1.rman log/home/oracle/rmanbak/script/log/rman_$DATE.log append
三、2级备份(从0级追加到现在的备份)
[oracle@oracle122 script]$ cat db_bak2.rman 
run
{
    configure retention policy to recovery window of 8 days;
    configure controlfile autobackup on;
    configure controlfile autobackup format for device type disk to '/home/oracle/rmanbak/%F';
    allocate channel ch1 device type disk format '/home/oracle/rmanbak/inc2_%d_%s_%p_%u_%T';
    backup incremental level 2 tag='level 2' database skip inaccessible filesperset 10 plus archivelog filesperset 20 delete all input;
    release channel ch1;
}
allocate channel for maintenance device type disk;
crosscheck backup;
delete noprompt expired backup;
delete noprompt obsolete;
2级运行脚本
[oracle@oracle122 script]$ cat exec_2_level.sh 
ORACLE_HOSTNAME=oracle122; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app; export ORACLE_BASE
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbinPATH; export PATH
PATH=$ORACLE_HOME/binPATH; export PATH
export DATE=$(date +%Y_%m_%d)
export NLS_LANG="Simplified Chinese_china".AL32UTF8
/u01/app/oracle/product/11.2.0/dbhome_1/bin/rman target sys/sys_admin cmdfile /home/oracle/rmanbak/script/db_bak2.rman log/home/oracle/rmanbak/script/log/rman_$DATE.log append
定时备份星期天为0级全备,星期三为2级备份,星期一,星期二,星期四,星期五,星期六为1级增量备份晚上11点开始备份
[oracle@oracle122 script]$ crontab -l
* 23 * *  0 /home/oracle/rmanbak/script/exec_0_level.sh 
* 23 * *  1 /home/oracle/rmanbak/script/exec_1_level.sh 
* 23 * *  2 /home/oracle/rmanbak/script/exec_1_level.sh 
* 23 * *  3 /home/oracle/rmanbak/script/exec_2_level.sh 
* 23 * *  4 /home/oracle/rmanbak/script/exec_1_level.sh 
* 23 * *  5 /home/oracle/rmanbak/script/exec_1_level.sh 
* 23 * *  6 /home/oracle/rmanbak/script/exec_1_level.sh
如果想深入体验LINUX系统的新手,也可以先下载一个方德Linux软件中心试用一下。
免费下载地址:

转载于:https://my.oschina.net/foundation00523wuxi/blog/600540

你可能感兴趣的文章
17岁时少年决定把海洋洗干净,现在21岁的他做到了
查看>>
《写给大忙人看的java se 8》笔记
查看>>
倒计时:计算时间差
查看>>
Linux/windows P2V VMWare ESXi
查看>>
Windows XP倒计时到底意味着什么?
查看>>
运维工程师在干什么学些什么?【致菜鸟】
查看>>
Linux中iptables详解
查看>>
java中回调函数以及关于包装类的Demo
查看>>
maven异常:missing artifact jdk.tools:jar:1.6
查看>>
终端安全求生指南(五)-——日志管理
查看>>
Nginx 使用 openssl 的自签名证书
查看>>
创业维艰、守成不易
查看>>
PHP环境安装套件:快速安装LAMP环境
查看>>
CSS3
查看>>
ul下的li浮动,如何是ul有li的高度
查看>>
C++ primer plus
查看>>
python mysqlDB
查看>>
UVALive 3942 Remember the Word Tire+DP
查看>>
从微软的DBML文件中我们能学到什么(它告诉了我们什么是微软的重中之重)~目录...
查看>>
被需求搞的一塌糊涂,怎么办?
查看>>