Tuesday, January 8, 2013

Shell Scripting of Deleting Archivelog on Standby / Dataguard Server


Frist Create file vi rman_script.sh

then add the following lines in rman_script.sh file

rman msglog " now.log " <<EOF
connect target /;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET;
run {
CROSSCHECK BACKUP;
DELETE NOPROMPT OBSOLETE;
DELETE NOPROMPT EXPIRED BACKUP;
delete noprompt archivelog until time 'SYSDATE-2';
crosscheck archivelog all;
}
Exit;
EOF

Note:- It will delete all the archive of 48 hours back. (SYSDATE-2) mean 48 Hours Past.

then save it and exit

then give the executing permission to rman_script.sh
chmod 777 rman_script.sh



now run the command 
crontab -e
and add the file in crontab ( Automatically Running Job )

00 6 * * *  "/u01/app/oracle/product/rman_script.sh" 

save it and exit and enjoy!!!!!


Note:- Try everything at your own risk, if any thing happens wrong with your database so blogger will not be responsible.

No comments:

Post a Comment