win平台oracle rman备份和删除dg备库归档日志脚本

总觉得使用windows跑oracle是不靠谱的事情,可以这个世界上总有很多人喜欢做类似这样的事情,对于数据库比较常见的两件事情:rman和删除dg备库归档日志,在linux/unix平台上使用shell实现很简单,可是跑到win里面,就变的烦了,不是因为其麻烦,而是因为用的人少,不知道怎么下手处理该事情,我编写了简单的实现初级功能的win下面rman备份和删除备库归档日志脚本,供大家参考,也更加欢迎朋友提出来更加好的处理方法(win是真心的不懂)

rman备份脚本


复制代码 代码如下:

–backup_oracle.bat文件

rman target / cmdfile=d:/backup/rman/backup_db.rman 

log=d:/backup/rman/logfile/rmanlog%date:~0,4%%date:~5,2%%date:~8,2%.log

–backup_db.rman文件

configure retention policy to redundancy = 2;

configure device type disk parallelism 2;

configure default device type to disk;

backup filesperset = 5 as compressed backupset database format ‘d:/backup/rman/full_%u.rman’;

sql ‘alter system archive log current’;

backup  filesperset = 50 as compressed backupset archivelog  all format ‘d:/backup/rman/arch_%u.rman’  delete input;

delete noprompt obsolete;

crosscheck backup;

delete noprompt expired backup;

backup  format ‘d:/backup/rman/ctl_%u.rman’ current controlfile;

backup spfile format ‘d:/backup/rman/spfile_%u.rman’ ;

exit;

backup_oracle.bat

 

文件加入到计划任务即可

删除dg备库归档日志(已经应用)


复制代码 代码如下:

–delete_dg_archivelog.bat

rem 注意修改 部署目录

cd d:/win_xifenfei

d:

rem 注意delete_archive.sql 查询是否有记录

echo delete archivelog staring > delete_archivelog.bak

sqlplus / as sysdba @delete_archive.sql

echo rman target / cmdfile=rman_checkcross.rman>>delete_archivelog.bat 

delete_archivelog.bat >>delete_dg_archivelog_%date:~0,4%%date:~5,2%%date:~8,2%”.log

exit

–delete_archive.sql

set lines 150

col name for a150

set pagesize 0 feedback off verify off heading off echo off

spool delete_archivelog.bat

select ‘del ‘||name from v$archived_log where applied=’yes’ and name is not null and dest_id=1;

spool off

exit;

–rman_checkcross.rman

crosscheck archivelog all;

delete noprompt expired archivelog all;

exit

delete_dg_archivelog.bat

 

加入到计划任务即可

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐