oracle11g rman备份文件失踪之谜

 

 

1rman备份文件失踪之谜

备份文件消失了,每天自动备份后,会删除前一天的备份文件,如下所示,这是怎么回事呢?

 

 

 

2,查看备份任务

[root@earth_dbm1data]# more/tmp/oracle_fullback.log

蛮简单的自动备份脚本,每天晚上1022分开始执行的:

[root@earth_dbm1 data]# crontab -l

10 22 * * */data/backup/scripts/rman_full_backup.sh >> /tmp/oracle_fullback.log 2>&1

[root@earth_dbm1 data]#

 

查看备份的日志,没有异常信息:

RMAN> 2> 3> 4> 5> 6>7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> begin to copy thebackup to pd servers.

end to copy the backup to pd server.

RMAN> 2> 3> 4> 5> 6>7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> begin to copy thebackup to pd servers.

end to copy the backup to pd server.

RMAN> 2> 3> 4> 5> 6>7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> begin to copy thebackup to pd servers.

end to copy the backup to pd server.

RMAN> 2> 3> 4> 5> 6>7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> begin to copy thebackup to pd servers.

end to copy the backup to pd server.

RMAN> 2> 3> 4> 5> 6>7> RMAN> RMAN> RMAN> RMAN> RMAN> RMAN> begin to copy thebackup to pd servers.

end to copy the backup to pd server.

[root@earth_dbm1data]# 

 

 

3,查看备份脚本日志

去查看备份脚本/data/backup/scripts/rman_full_backup.sh里面的日志rman_backup.log,然后看到如下记录:


 

从日志文件看到如下信息:

……

Deleting the following obsoletebackups and copies:

……

backup piecehandle=/data/backup/data/2016-06-30/full_POWERDES_20160630_164.bak RECID=164STAMP=915919808

deleted backup piece

……

表明说在备份的过程中,会删除掉以前的备份记录,那么这个是rman的机制造成的,其策略是啥?

 


4,问题分析

查询到rman有一个备份管理器,RMAN提供了CONFIGURERETENTION POLICY命令设置备份保存策略,即设置备份文件保留多长时间。RMAN会将超出时间的备份文件标识为废弃(obsolete)。命令REPORT OBSOLETE和DELETE OBSOLETE分别用来查看废弃的文件和删除废弃的文件。RMAN跟踪备份的数据文件、控制文件、归档日志文件,并确定哪些需要保存,哪些需要标记为废弃。但RMAN不自动删除废弃的备份文件。

 

 

然后再去看备份脚本,有delete noprompt obsolete;如下所示

[root@earth_dbm1data]# crontab -l

10 22 * * * /data/backup/scripts/rman_full_backup.sh  >> /tmp/oracle_fullback.log 2>&1

[root@earth_dbm1data]# more /data/backup/scripts/rman_full_backup.sh

#!/bin/sh

export DATE=`date +%F`

export BACK_DIR='/data/backup/data'

su - oracle -c "

mkdir -p $BACK_DIR/$DATE

rman log=$BACK_DIR/$DATE/rman_backup.log target / <<EOF

run{

        backup as compressed backupset database

                format '$BACK_DIR/$DATE/full_%d_%T_%s.bak'

        plus archivelog

                format '$BACK_DIR/$DATE/arch_%d_%T_%s.bak' delete input;

        sql 'alter system archive log current';

}

crosscheck backup;

crosscheck archivelog all;

delete noprompt expired backup;

delete noprompt expired archivelog all;

delete noprompt obsolete;  #删除过期的所有备份记录

exit

EOF

"

su - oracle -c "

chmod 775 $BACK_DIR/$DATE/*

"

 

#cd /home/pdbcakup/

echo "begin to copy the backup to pd servers." >>  /tmp/oracle_fullback.log

#cp -r $BACK_DIR/$DATE /home/pdbcakup

echo "end to copy the backup to pd server." >>  /tmp/oracle_fullback.log

[root@earth_dbm1data]#

 

果然是delete noprompt obsolete;引起的,到此问题已经知道是怎么回事了,设置delete noprompt obsolete;了导致rman备份完后会删除超出失效日期的备份文件,而oracle默认的有效rman备份文件就是一天,所以才会出现每天自动备份完后,以前的备份记录都失踪了。

 

 

 

5,解决问题

解决办法有以下途径:

(1)      去掉delete noprompt obsolete;

(2)      延长rman备份文件的有效期

 

这里采用第二种解决方案,设置rman备份保存时间为60天。

# 新的 RMAN 配置参数

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 60 DAYS;

 

using target database control file instead of recovery catalog

new RMAN configuration parameters:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 60 DAYS;

new RMAN configuration parameters are successfully stored

 

RMAN>

#已成功存储新的 RMAN 配置参数

 

6,问题解决

第二天然后再等去看备份结果,就可以看到不会再删除昨天的备份了。

[root@earth_dbm1 data]# du -sh *

......

12K  2016-06-26

12K  2016-06-27

12K  2016-06-28

12K  2016-06-29

12K  2016-06-30

4.4G          2016-07-01

4.4G          2016-07-02

[root@earth_dbm1 data]#

 

 

你可能感兴趣的:(oracle11g rman备份文件失踪之谜)