Hi experts,
My objectives is to backup a production database by utilizing the NetApp Snapshot and shell script. The database will be placed into the HOT MODE -> Take Snapshot of Database -> Return to NORMAL MODE. In order to do that, I need to enable ARCHIVELOG for the database. Since my FRA space is not big (limit to less than 50GB) so I have to configure RMAN to automatically delete the archivelog.
So this is what I've done so far:
- Auto backup all archivelog
- Delete the archivelog on FRA area that is older than 2 weeks -> just in case for restore.
- Check the archivelog by using RMAN
- Delete the expired archivelog to reclaim the space
- Run the shell script to bring the database to hotmode -> normal mode.
Below is my scripts. Could you please help to take a look if it is fitted to my purpose? Thanks
RMAN Script:
run {
allocate channel disk1 type disk;
backup archivelog all;
delete noprompt archivelog all completed before 'SYSDATE-14';
crosscheck archivelog all;
delete noprompt expired archivelog all;
release channel disk1;
}
HOT MODE script:
#!/bin/bash
DATE=$(date +%Y%m%d)
#Declare Oracle Environment
export ORACLE_SID=st2015
export ORACLE_BASE=/apps/oracle12
export ORACLE_HOME=/apps/oracle12/OraHome
export PATH=$PATH:${ORACLE_HOME}/bin
sqlplus /nolog <<EOF
connect / as sysdba
alter database begin backup;
alter system switch logfile ;
alter database backup controlfile to '/data/ora_bkup/bk_ctlfile/controlbkup_hotmode.dbf';
EOF
mv /data/ora_bkup/bk_ctlfile/controlbkup_hotmode.dbf /data/ora_bkup/bk_ctlfile/controlbkup_hotmode_$DATE.dbf
exit
NORMAL MODE script:
#!/bin/bash
DATE=$(date +%Y%m%d)
#Declare Oracle Environment
export ORACLE_SID=st2015
export ORACLE_BASE=/apps/oracle12
export ORACLE_HOME=/apps/oracle12/OraHome
export PATH=$PATH:${ORACLE_HOME}/bin
sqlplus /nolog <<EOF
connect / as sysdba
alter database end backup;
alter SYSTEM switch logfile;
alter database backup controlfile to '/data/ora_bkup/bk_ctlfile/controlbkup_normode.dbf';
EOF
mv /data/ora_bkup/bk_ctlfile/controlbkup_normode.dbf /data/ora_bkup/bk_ctlfile/controlbkup_normode_$DATE.dbf