ORCLE RMAN备份脚本

1、Linux下oracle备份脚本

export ORACLE_BASE=/u01/app/oracle

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1

export PATH=$PATH:$ORACLE_HOME/bin:

export NLS_LANG=AMERICAN_AMERICA.zhs16gbk

export ORACLE_SID=orcl

rman target / nocatalog log=/tmp/rman_full.log append<<EOF

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 3 database format ‘/oracle/backup/full_%d_%T_%s_%p‘;

sql ‘alter system archive log current‘;

sql ‘alter system archive log current‘;

sql ‘alter system archive log current‘;

backup archivelog all format ‘/oracle/backup/arch_%d_%T_%s_%p‘ delete input;

backup current controlfile format ‘/oracle/backup/ctl_%d_%T_%s_%p‘;

}

EOF

Linux下删除过期备份的脚本

rman target / nocatalog log=/tmp/rman_delete.log append<<EOF

run{

allocate channel for maintenance type disk;

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time ‘sysdate-1‘;

delete noprompt obsolete;

}

EOF

注:将脚本添加到crontab中定时执行即可。

2、windows下ORACLE备份脚本

全库备份脚本full_backup.txt

run{

allocate channel c1 type disk;

allocate channel c2 type disk;

backup filesperset 2 database format ‘d:\u01\rman\full_%d_%T_%s_%p‘;

sql ‘alter system archive log current‘;

sql ‘alter system archive log current‘;

sql ‘alter system archive log current‘;

backup archivelog all format ‘d:\u01\rman\arch_%d_%T_%s_%p‘ delete input;

backup current controlfile format ‘d:\u01\rman\ctl_%d_%T_%s_%p‘;

backup spfile format ‘d:\u01\rman\spfile_%d_%T_%s_%p‘;

}

exit

全库备份可执行脚本full_backup.bat

rman target / nocatalog log=d:\u01\rman.log append CMDFILE ‘d:\u01\full_backup.txt‘;

归档日志备份脚本log_backup.txt

run{

backup archivelog all format ‘d:\u01\rman\arch_%d_%T_%s_%p‘ delete input;

}

exit

删除过期备份脚本delete_obsolete.txt

run{

crosscheck backup;

crosscheck archivelog all;

delete noprompt archivelog until time ‘sysdate-1‘;

delete noprompt obsolete;

}

exit

注:windows下备份需要添加定时任务

时间: 2024-11-11 08:29:45

ORCLE RMAN备份脚本的相关文章

Oracle 11g R2 RAC RMAN备份脚本示例

一.将RAC切换成归档模式 1. 修改数据库的归档模式,通常在安装RAC的时候都会配置归档并且使用闪回区,已经配置过归档下面的方式可以略过. SQL> alter system set cluster_database=false scope=spfile sid='*'; 2. 关闭所有实例(两边都要shutdown) SQL> shutdown immediate 或直接关闭所有实例   $ srvctl stop database -d orcl 3. 在任意一个实例上将数据库启动到mo

rman备份脚本

在数据库中启用块跟踪 alter database enable block change tracking: alter database enable block change tracking using file '/u01/app/oracle/track/blockchange.trc': 取消块跟踪 alter database disable block change tracking 查看是否启动块跟踪 SQL> select * from v$block_change_tra

RMAN备份脚本执行遇到RMAN-03002,06091问题处理

一 问题描述 客户说RMAN备份脚本执行有的时候报错,有的时候正常!!! 远程登陆客户环境,查询最后一次备份的日志报错信息,得到 RMAN-03002: failure of delete command at xxx   RMAN-06091: no channel allocated for maintenance (of an appropriate type) 二 参考链接 https://www.linuxidc.com/Linux/2013-01/78144.htm Encounte

rman备份脚本shell版

1.数据库全备到硬盘 [[email protected] scripts]$ cat rman_backup.sh   source /home/oracle/.bash_profile   rman target / log=/home/oracle/backup/backupall_rman.log<<EOF   run   {   allocate channel ch1 device type disk;  #分配通道   allocate channel ch2 device ty

oracle数据库中rman备份脚本非常实用

查询字符集 SQL> select * from nls_database_parameters; NLS_CHARACTERSETAL32UTF8 备份时字符集很重要,不然会出乱码 一.0级备份(全备)红色是要修改的,根据个人的存放位置. [[email protected] script]$ cat db_bak0.rman run{    configure retention policy to recovery window of 8 days;    configure contro

Oracle Rman备份脚本与自动删除重复备份文件

#!/bin/sh source /home/oracle/.bash_profile if [ -z $1 ] then echo "Please Input a number,Usage: 0|1|2" exit else RMAN_LEVEL=$1 fi export ORACLE_SID=xxxx export TODAY=`date '+%Y%m%d'` export RMAN_DIR=/backup/archivelog/rman/$ORACLE_SID/$TODAY-$R

rman 备份脚本

[[email protected] ~]$ ls Desktop oracle_backup.rman oracle_backup.sh [[email protected] ~]$ cat oracle_backup.rman run{ CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS; C

一周RMAN备份脚本

#! /bin/bash#crontab---->00 20 * * 0 su - oracle -c '/scripts/oracle_full_backup.sh'#crontab---->00 20 * * 1-6 su - oracle -c '/scripts/oracle_inc_backup.sh'export BACKUP_DIR=/backupexport ORACLE_HOME=/oracle/oracle/product/11.2.0/db_1#exec >>

linux 下RMAN备份shell脚本

RMAN备份对于Oracle数据库的备份与恢复简单易用,成本低廉.对于使用非catalog方式而言,将RMAN脚本嵌入到shell脚本,然后再通过crontab来实现中小型数据库数据库备份无疑是首选.本文提供了一个简单易用的基于linux shell下的RMAN备份脚本供参考.大家可根据自己的需要进行适当调整. RMAN备份相关方面的知识较多,可以参考:    RMAN 概述及其体系结构    RMAN 配置.监控与管理    RMAN 备份详解    RMAN 还原与恢复    RMAN ca