This article will introduce to you how to back up and delete the scripts for archiving logs of the dg standby database on the win platform rman. I hope this method will be helpful to you.
I always think that using windows to run oracle is unreliable. But there are always many people in the world who like to do something like this. There are two common things about databases: rman and delete the archive logs of the dg slave database. It is very easy to use shell on linux/unix platforms, but it is annoying to run to win, not because of its troubles, however, I don't know how to handle this issue because there are few users. I have compiled a simple script to back up and delete the backup database archive logs under win for your reference, you are also more welcome to come up with a better solution (win is really not understanding)
Rman backup script
The Code is as follows: |
Copy code |
-- Backup_oracle.bat File Rman target/recovery file = 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 File 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 |
Add the file to the scheduled task.
Delete the archive logs of the dg slave database (applied)
The Code is as follows: |
Copy code |
-- Delete_dg_archivelog.bat Rem pay attention to modifying the deployment directory Cd D:/win_xifenfei D: Rem note delete_archive. SQL query records
Echo delete archivelog staring> delete_archivelog.bak Sqlplus/as sysdba @ delete_archive. SQL Echo rman target/destination file = 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 |
Join the scheduled task.