Aim:
we have the new feature of DBMS_SCHEDULER job type “BACKUP_SCRIPT”, that allows us to create backup jobs without creating them as an OS file, and without need for a wrapper script that’s called by a job type EXECUTABLE.
This is an example to create a scheduler job to run a backup job in 12c. With the introduction of backup_script in 12c, we can directly write scripts as if the RMAN interpreter is already invoked.
Solution:
1. Create a common user inside the container database
sql>create user bkpuser identified by bkpuser;
sql>grant connect, resource, create job, create external job, create credential to bkpuser;
2. Create a credential logged in as the common user. This ensures that script runs as the correct OS user on the server:
sql>begin
dbms_credential.create_credential(
credential_name => 'oracle_bkpuser',
username => 'oracle',
password => 'orclpswd'
);
end;
/
3. Prepare an rman script
$ vi sample_bkp.rman
connect target /
RUN
{
backup database plus archivelog;
crosscheck backup;
crosscheck archivelog all;
};
4. Create the scheduler job
sql> begin
dbms_scheduler.create_job(
job_name => sample_backup_job,
job_type => 'backup_script',
job_action => '/u01/app/oracle/scripts/sample_bkp.rman',
credential_name => 'oracle_bkpuser',
enabled => true
);
end;
/
5. Check the job status
column job_name format a20
select job_name, status, error# from dba_scheduler_job_run_details
where job_name=upper('&job_name); -- Provide the job name "sample_backup_job"
we have the new feature of DBMS_SCHEDULER job type “BACKUP_SCRIPT”, that allows us to create backup jobs without creating them as an OS file, and without need for a wrapper script that’s called by a job type EXECUTABLE.
This is an example to create a scheduler job to run a backup job in 12c. With the introduction of backup_script in 12c, we can directly write scripts as if the RMAN interpreter is already invoked.
Solution:
1. Create a common user inside the container database
sql>create user bkpuser identified by bkpuser;
sql>grant connect, resource, create job, create external job, create credential to bkpuser;
2. Create a credential logged in as the common user. This ensures that script runs as the correct OS user on the server:
sql>begin
dbms_credential.create_credential(
credential_name => 'oracle_bkpuser',
username => 'oracle',
password => 'orclpswd'
);
end;
/
3. Prepare an rman script
$ vi sample_bkp.rman
connect target /
RUN
{
backup database plus archivelog;
crosscheck backup;
crosscheck archivelog all;
};
4. Create the scheduler job
sql> begin
dbms_scheduler.create_job(
job_name => sample_backup_job,
job_type => 'backup_script',
job_action => '/u01/app/oracle/scripts/sample_bkp.rman',
credential_name => 'oracle_bkpuser',
enabled => true
);
end;
/
5. Check the job status
column job_name format a20
select job_name, status, error# from dba_scheduler_job_run_details
where job_name=upper('&job_name); -- Provide the job name "sample_backup_job"