ora_full_backup.sh

本文介绍了一个用于 Oracle 数据库的 RMAN 自动备份脚本。该脚本能够检查 Oracle 是否启动,并通过 RMAN 执行数据库及归档日志的完全备份,同时进行日志轮转和清理过期备份。

#!/bin/bash

BACKUP_DIR="/home/yshuai/works/2008-12-10_NPS61_ED2/backup_recovery/02_cluster/backup_scripts/gen2"

. /home/oracle/.bash_profile

 

# test if db on this node

sqlplus -L testuser/testuser | grep ORA-01017 > /dev/null

if [ $? -ne 0 ]; then

  now=`date '+%Y-%m-%d %H:%M:%S'`

  echo "Error: Oracle not start, can not perform full backup! ($now)" |tee -a $BACKUP_DIR/rmanErr.log

  exit

fi

 

# rotate logs

for i in 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

do

next=`expr $i + 1`

test -f $BACKUP_DIR/rman.log.$i && mv $BACKUP_DIR/rman.log.$i $BACKUP_DIR/rman.log.$next

done

 

#rman script

$ORACLE_HOME/bin/rman target / <<EOF > $BACKUP_DIR/rman.log.0

configure retention policy to recovery window of 15 days;

CONFIGURE CONTROLFILE AUTOBACKUP ON;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$BACKUP_DIR/%F';

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO COMPRESSED BACKUPSET;

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '$BACKUP_DIR/%U';

crosscheck archivelog all;

backup database plus archivelog;

delete noprompt archivelog all backed up 2 times to device type disk;

crosscheck backup;

delete noprompt obsolete;

exit;

EOF

RMAN> backup database plus archivelog; Starting backup at 22-OCT-25 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=86 device type=DISK channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=10 RECID=7 STAMP=1214750292 channel ORA_DISK_1: starting piece 1 at 22-OCT-25 channel ORA_DISK_1: finished piece 1 at 22-OCT-25 piece handle=/u01/app/oracle/fast_recovery_area/ORCL/backupset/2025_10_22/o1_mf_annnn_TAG20251022T091505_nhjd0s8j_.bkp tag=TAG20251022T091505 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 22-OCT-25 Starting backup at 22-OCT-25 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/testdb01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf channel ORA_DISK_1: starting piece 1 at 22-OCT-25 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of backup plus archivelog command at 10/22/2025 09:15:09 ORA-19809: limit exceeded for recovery files ORA-19804: cannot reclaim 67108864 bytes disk space from 4385144832 limit
10-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值