Thursday, March 20, 2014

Script to delete archive logs on standby server (oracle)

Frist Create file vi rman_script.sh

then add the following lines in rman_script.sh file

#!/bin/bash
###################################################################
#  this script will delete the archive and obsolete file on standby server  ##########
###################################################################

ORACLE_HOME=/u01/app/oracle/product/11.2/db_1;
export ORACLE_HOME;
ORACLE_SID=ORCL;
export ORACLE_SID;

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-7';
crosscheck archivelog all;
}
Exit;
EOF


Note:- It will delete all the archive of 7 days back. (SYSDATE-7) .
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"

No comments:

Post a Comment