win Platform oracle rman Backup and Delete dg Backup Library Archive Log Scripts

  • 2021-09-12 02:33:34
  • OfStack

I always feel that it is unreliable to use windows to run oracle, But there are always many people in this world who like to do things like this. Two things that are common to databases: rman and delete dg standby archive logs, The implementation using shell on the linux/unix platform is simple, But run to win inside, become bored, not because of its trouble, but because of the use of less people, do not know how to deal with the matter, I wrote a simple implementation of the primary functions of win below rman backup and delete reserve library archiving log script, for your reference, but also more welcome friends to put forward a better treatment method (win is really don't understand)
rman Backup Script
 
--backup_oracle.bat Documents  
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 Documents  
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
 

You can add the file to the scheduled task
Delete dg standby archive log (already applied)

--delete_dg_archivelog.bat 
rem  Pay attention to modifications   Deployment directory  
cd D:/win_xifenfei 
d: 
rem  Attention delete_archive.sql  Query whether there are records  

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
 

Just add to the scheduled task

Related articles: