Oracle rman on win platform backs up and deletes the log script for archiving the dg slave Database

Source: Internet
Author: User

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
Copy codeThe Code is as follows:
-- 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)
Copy codeThe Code is as follows:
-- 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.