You are on page 1of 1

I work as an Oracle Applications DBA, and I still use this for monthly cold backups.

The rest of the time, I use RMAN. The below SQL select statement coupled with the case statement sets the rotating backup destination. The use of the Julian calendar makes this very straight forward since there are no leap years or differing length months for which to account, just a series of days stacking up. Julian Week Modulus in Oracle (useful for programmatic rotation), from a shell script backup: select mod(trunc(to_number(to_char(sysdate,'J'))/7),2) from dual from shell script backup config: # BACKUP SITE # Need error handling to check for available space. If it is not there, quit. case ${JULIAN_WEEK_MODULUS} in # 0) export MOUNT_POINT="Orabak3/TEST_BACKUPS" # ;; 0) export MOUNT_POINT="Orabak2/PRODUCTION_BACKUPS" ;; 1) export MOUNT_POINT="Orabak1/PRODUCTION_BACKUPS" ;; esac Side Note: You will notice that I said monthly backups above and use week in the algorithm. Writing the algorithm for a monthly cycle would be unnecessarily complicated. I would approach an automated monthly rotation differently, e.g. month names in a case statement and assigned from execution of "date". Since I only care about being alerted so that I can confirm available storage, I do not want to put out the effort for a rewrite. Links: http://forum.junowebdesign.com/php-articles/22435-what-modulus-how-do-iuse.html http://www.daniweb.com/software-development/computerscience/threads/185693 http://embeddedgurus.com/stack-overflow/2011/02/efficient-c-tip-13-usethe-modulus-operator-with-caution/ 2011, Kevin Stone O'Brien

You might also like