Oracle 常用 RMAN 备份

1、全量备份

#!/bin/bash

export ORACLE_SID=ynsb1;
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1;
export RECORD_TIME=$(date +%y%m%d%H%M%S);
find /backup/rmandata/ -name "level_0_*.log" -mtime +15 -exec rm {} \;
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/rman log=/backup/rmandata/level_0_$RECORD_TIME.log append <<EOF
connect target sys/ynsb_2022_adminsys@YNSBBKP
run
{
  allocate channel c1 type disk maxpiecesize=20G;
  allocate channel c2 type disk maxpiecesize=20G;
  allocate channel c3 type disk maxpiecesize=20G;
  allocate channel c4 type disk maxpiecesize=20G;
  allocate channel c5 type disk maxpiecesize=20G;
  allocate channel c6 type disk maxpiecesize=20G;
  allocate channel c7 type disk maxpiecesize=20G;
  allocate channel c8 type disk maxpiecesize=20G;
  backup as compressed backupset incremental level 0 database format='/backup/rmandata/ynsb_full_l0_%U.BKU' tag='ynsb_lev_0_$RECORD_TIME';
  sql 'alter system archive log current';
  backup as compressed backupset archivelog all tag='arc_bak_$RECORD_TIME' format='/backup/rmandata/arch_%U_%T' not backed up 1 times;
  backup current controlfile tag='ctlfile_bak_$RECORD_TIME' format='/backup/rmandata/ctl_file_%U_%T';
  backup spfile tag='spfile_bak_$RECORD_TIME' format='/backup/rmandata/spfile_%U_%T';
}
crosscheck backup of archivelog all;
delete noprompt obsolete;
exit;
EOF

2、增量备份

#!/bin/bash

export ORACLE_SID=ynsb1;
export ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1;
export RECORD_TIME=$(date +%y%m%d%H%M%S);
find /backup/rmandata/ -name "level_1_*.log" -mtime +15 -exec rm {} \;
/u01/app/oracle/product/19.0.0.0/dbhome_1/bin/rman log=/backup/rmandata/level_1_$RECORD_TIME.log append <<EOF
connect target sys/ynsb_2022_adminsys@YNSBBKP
run
{
  allocate channel c1 type disk maxpiecesize=20G;
  allocate channel c2 type disk maxpiecesize=20G;
  allocate channel c3 type disk maxpiecesize=20G;
  allocate channel c4 type disk maxpiecesize=20G;
  allocate channel c5 type disk maxpiecesize=20G;
  allocate channel c6 type disk maxpiecesize=20G;
  allocate channel c7 type disk maxpiecesize=20G;
  allocate channel c8 type disk maxpiecesize=20G;
  backup as compressed backupset incremental level 1 database format='/backup/rmandata/ynsb_inc_l1_%U.BKU' tag='ynsb_lev_1_$RECORD_TIME';
  sql 'alter system archive log current';
  backup as compressed backupset archivelog all tag='arc_bak_$RECORD_TIME' format='/backup/rmandata/arch_%U_%T' not backed up 1 times;
  backup current controlfile tag='ctlfile_bak_$RECORD_TIME' format='/backup/rmandata/ctl_file_%U_%T';
}
exit;
EOF

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ahern_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值