rman备份到本地,通常会写一个shell(创建日期目录、备份、删除过期的),然后crontab定期执行。现在的新方法可以是:
-
1、创建用户
-
create user c##bkpuser identified by bkpuser container=all;
-
grant connect, resource, create job, create external job, create credential to c##bkpuser;
-
-
2、创建凭证
-
begin
-
dbms_credential.create_credential(
-
credential_name => 'oracle_bkpuser',
-
username => 'oracle',
-
password => 'orclpswd'
-
);
-
end;
-
/
-
-
3、准备脚本
-
vi sample_bkp.rman
-
connect target /
-
RUN
-
{
-
backup database plus archivelog;
-
crosscheck backup;
-
crosscheck archivelog all;
-
};
-
-
4、创建scheduler job
-
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;
-
/
-
-
检查job状态
-
column job_name format a20
-
select job_name, status, error# from dba_scheduler_job_run_details
-
where job_name=upper('SAMPLE_BACKUP_JOB');
-
可能有人觉得看日志不太方便,而且不是滚动保留一段时间,这个可以通过设置保留策略,然后delete obsolete实现。
阅读(1144) | 评论(0) | 转发(0) |