Backup incremental level and scripts

1. Full backup

run {

allocate channel 'dev1' type disk   ;

allocate channel 'dev2' type disk ;

allocate channel 'dev3' type disk ;

backup full  tag 'dbfull' format '/o9i/testrman/full%u_%p_%c' database ;

sql 'alter system archive logcurrent' ;

backup filesperset 3   archivelog all delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

2. Level0 backup(Except the offline tablespace)

run {

allocate channel 'dev1' type disk   ;

allocate channel 'dev2' type disk ;

allocate channel 'dev3' type disk ;

backup incremental level 0  tag 'dbL0' format'/o9i/testrman/basic%u_%p_%c' database skip readonly;

sql 'alter system archive logcurrent' ;

backup filesperset 3   archivelog all delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

3. TheLevel 1 backup

run {

allocate channel 'dev1' type disk   ;

allocate channel 'dev2' type disk ;

allocate channel 'dev3' type disk ;

backup incremental level 1  tag 'dbL1' format'/o9i/testrman/basic%u_%p_%c' ddatabase skip readonly;     # Don't use it if it is unnecessary.

sql 'alter system archive logcurrent' ;

backup filesperset 3   archivelog all delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

4. TheLevel 2 backup

run {

allocate channel 'dev1' type disk;

allocate channel 'dev2' type disk;

allocate channel 'dev3' type disk;

backup incremental level 2  tag 'dbL2' format'/o9i/testrman/basic%u_%p_%c' ddatabase skip readonly;

sql 'alter system archive logcurrent' ;

backup filesperset 3   archivelog all delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

5. Backup someone tablespace(Like ‘users’)

run {

allocate channel 'dev1' type disk   ;

allocate channel 'dev2' type disk ;

allocate channel 'dev3' type disk ;

backup tag 'tsusers' format'/o9i/testrman/basic%u_%p_%c' tablespace users;

sql 'alter system archive logcurrent' ;

backup filesperset 3  archivelog all delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

6. Backup the archive log

run {

allocate channel 'dev1' type disk   ;

allocate channel 'dev2' type disk ;

allocate channel 'dev3' type disk ;

backup filesperset 3 archivelogall delete input;

release channel dev1;

release channel dev2;

release channel dev3;

}

 

7. Backp the CATALOG(Just use the exp/imp)

exp pafile=exp.dat

$ vi exp.dat

userid=rman/rman

file=rmanexp.dmp

 

8. The rman back scripts

/opt/oracle/rman_compbak/bin

/opt/oracle/rman_compbak/data

/opt/oracle/rman_compbak/arch

/opt/oracle/rman_compbak/log

In the bin folder:

--- 1). Filename: backup_cldb.cmd

run {
#Hot database level 0 whole backup
#allocate channel t1 type disk connect 'sys/oracle';
#allocate channel t2 type disk connect 'sys/oracle';
allocate channel t1 type disk;
allocate channel t2 type disk;
backup
  incremental level 0
  #skip inaccessible
  #filesperset 6 
  #recommended format
  format '/opt/oracle/rman_compbak/data/db_%s_%p_%T_%d'
  # AS COMPRESSED backupset
  (database);
  #delete obsolete;
sql 'alter system archive log current';
#backup all archive logs
backup
  #skip inaccessible
  #filesperset 10
  format '/opt/oracle/rman_compbak/arch/arclogback_%s_%p_%t_%d'
  # AS COMPRESSED backupset
  (archivelog all delete input);
  #delete obsolete;
BACKUP
  FORMAT '/opt/oracle/rman_compbak/data/cntrl_%s_%p_%t'
  CURRENT CONTROLFILE;
release CHANNEL t1 ;
release CHANNEL t2 ;
}

--- 2). Filename: backup_db.sh

rman target / nocatalog cmdfile=/opt/oracle/rman_compbak/bin/backup_cldb.cmd 1>>/opt/oracle/rman_compbak/log/backup_db.log 2>&1

--- 3). Filename: arch_back.cmd

run {
allocate channel t1 type disk;
sql 'alter system archive log current';
#backup all archive logs
backup
  skip inaccessible
  #filesperset 10
  format '/opt/oracle/rman_compbak/arch/arclogback_%s_%p_%t_%d'
  # AS COMPRESSED backupset
  (archivelog all delete input);
#delete obsolete;
release CHANNEL t1 ;
}

--- 4). Filename: arch_back.sh

rman target / nocatalog cmdfile=/opt/oracle/rman_compbak/bin/arch_back.cmd 1>>/opt/oracle/rman_compbak/log/backup_arch.log 2>&1

 

9. Add the jobs

Login using the rootuser:

# crontab -e 

Add two rows:

# 2:00 am erveryday

0 2 * * * su - oracle -c/opt/oracle/rman_compbak/bin/backup_db.sh

#ervery 3 hours(If the full backup didn’t finished in the 4 hours, don’tbegin to backup the archive, and need to delay.)

0 0,6,9,12,15,18,21 * * * su - oracle -c /opt/oracle/rman_compbak/bin/arch_back.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值