Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

automatic rman backups with the Oracle scheduler

VIEWS: 13 PAGES: 6

									Automatic RMAN Backup with Oracle
Scheduler
Since version 10g Oracle provides a new job scheduling mechanism named scheduler. There are
several advantages over the old dbms_job function but as often the documentation and the various
functions is more confusing than helpful. In 11g we have 7 (!) different functions (Scheduler Chains,
Scheduler Programs, Scheduler Schedules, Scheduler Jobs, Scheduler Job Classes, Scheduler
Windows, Scheduler Window Groups) so you might say “let’s better go with the unix cron!”.
But in most of the cases the daily usage is much simpler: I normally only use Scheduler Programs and
Scheduler Jobs so I removed the others from my Toad Schema Browser menu.




Picture 1: Schema Browser Configuration

With these two functions I’m able to create Jobs which can be executed inside the database (PL/SQL
procedure) or outside the database as shown in the following example.

RMAN Scheduling
The Oracle scheduler is able to call operating system commands on the server. Unfortunately it is very
complicate to tell the Oracle scheduler to execute a command with a script (e.g. rman rcvfile=…).
Therefore I prefer to create a small shell scripts on Unix or Linux systems which only needs one variable
(ORACLE_SID) and includes the RMAN commands.



Johannes Ahrends                               Page 1 of 6                                  07.01.2009
A script can look like this:
#!/bin/sh
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
export PATH
if [ $# -ne 1 ]
then
       echo "Usage: $0 [ORACLE_SID]"
       exit
fi
ORACLE_SID=$1
ORAENV_ASK=NO
. oraenv
unset ORAENV_ASK
shift
rman target / <<EOF
CROSSCHECK ARCHIVELOG ALL;
BACKUP DATABASE;
BACKUP ARCHIVELOG ALL NOT BACKED UP 2 TIMES;
DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE - 3';
EOF
                                Script 3: Shell Script for RMAN-Backup

I normally store this script named rman.sh into the /usr/local/bin directory. Now I’m able to use
Toad to create a scheduler job.
First I create a scheduler program named FULLDB_PROG which mainly includes the name of the
executable (/usr/local/bin/rman.sh) and some variables (in our case the ORACLE_SID):




Johannes Ahrends                            Page 2 of 6                               07.01.2009
                                   Figure 5: Scheduler Program Info




                                Figure 6: Scheduler Program Arguments

Now I’m creating the scheduler job named Backup_JOB. Don’t forget to enable the job by checking the
Enable button.



Johannes Ahrends                            Page 3 of 6                                07.01.2009
                                      Figure 7: Scheduler Job Basic Info



In the tab Scheduler Info the start date (midnight) for the first execution is specified and the execution
interval (once per day).




Johannes Ahrends                                Page 4 of 6                                    07.01.2009
                                  Figure 8: Scheduler Job Schedule Info

Useful Tip: because the time syntax for the scheduler is not easy you might want to use the right mouse
button and see some examples like “Weekdays at 7 am and 3 pm” to change them accordingly.
In the tab “Program Info“ I now add the name for the scheduler program (FULLDB_PROG)




Johannes Ahrends                              Page 5 of 6                                 07.01.2009
                                    Figure 9: Scheduler Job Program Info

You can verify if the execution of your script was successful in the “Run Log” tab of the scheduler job.




                                     Figure 10: Scheduler Job Run Log




Johannes Ahrends                               Page 6 of 6                                   07.01.2009

								
To top