Search code examples
oraclerman

Is this a valid way to use the Oracle Recovery Manager with the Oracle Job Scheduler?


First, I am creating an executable job:

BEGIN
  DBMS_SCHEDULER.CREATE_JOB(job_name => 'PIPE_JOB', job_type => 'EXECUTABLE', job_action => 'RMAN PIPE TEST_PIPE_1 target / TIMEOUT = 60');
END;

Next, I am trying to execute the job with this series of Oracle commands:

DECLARE
  pipename CONSTANT VARCHAR2(100) := 'TEST_PIPE_1';
  create_result INTEGER;
  send_result INTEGER;
BEGIN
  create_result := DBMS_PIPE.CREATE_PIPE(pipename);
  DBMS_PIPE.PACK_MESSAGE('BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DEVICE TYPE DISK DATABASE INCLUDE CURRENT CONTROLFILE;');
  send_result := DBMS_PIPE.SEND_MESSAGE(pipename);
  DBMS_SCHEDULER.RUN_JOB(job_name => 'PIPE_JOB', use_current_session => false);
END;

Now, when I make the call to RUN_JOB, the RMAN executable fires up on the server, but then immediately exits, presumably because it never receives the commands that I am attempting to pack into the pipe.

How can I use pipes correctly to make RMAN receive the commands I am trying to send it?


Solution

  • I don't think you can use DBMS_PIPE for this. It is a PL/SQL 'thing' and not something RMAN can deal with, and not like unix pipes to STDIN.

    You can do parameters with DBMS_SCHEDULER though. You may need an intervening shell script.

    [Added] I'd have a shell script that takes one or more parameters

    dbms_scheduler.create_job
    (
    job_name => 'job1',
    job_type => 'EXECUTABLE',
    job_action => '/somewhere/rman_script.sh',
    enabled => false,
    number_of_arguments => 2,
    comments => 'Run shell-script'
    );
    dbms_scheduler.set_job_argument_value(SHELL || jobidx,1,'blah');
    dbms_scheduler.set_job_argument_value(SHELL || jobidx,2,'blah');
    dbms_scheduler.enable('job1');
    

    The shell script would call RMAN and pipe the parameters to it through STDIN.