oracle rman不能自动删除归档日志备份解决

发现在日常备份中,rman无法将过期的归档日志备份删除,查相关资料,
delete noprompt backup completed before 'sysdate-2';    可通过该语句将所有备份记录删除,包括归档日志备份。

整理的脚本如下:


10 20 * * * su - oracle -c "/oracle/script/fullbackup.sh"
10 12 * * * su - oracle -c "/oracle/script/arcbk.sh"

先设置rman备份保留可恢复数据库到前两天的时间;
 RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 days;
 

oracle@ciqdb:~/script> cat fullbackup.sh
echo '=======start backup====================================='>>/rmanfs/rmandb.log
date >>/rmanfs/rmandb.log
$ORACLE_HOME/bin/rman target / log /rmanfs/rmandb.log append < run {  
crosscheck backup;
delete noprompt expired backup device type disk;
allocate channel DISK_2 type disk format '/rmanfs/fulldb_%T_%u';
##backup  database  include current controlfile ;
backup as compressed backupset  
   ( database  include current controlfile );
}
allocate channel for maintenance device type disk;
delete noprompt archivelog until time 'sysdate - 8';
delete noprompt obsolete device type disk;
delete noprompt backup completed before 'sysdate-2';
EOF
date >>/rmanfs/rmandb.log
echo '======stop backup====================================-='>>/rmanfs/rmandb.log
oracle@ciqdb:~/script> cat arcbk.sh
echo '=======start backup====================================='>>/rmanfs/rmanarc.log
date >>/rmanfs/rmanarc.log
$ORACLE_HOME/bin/rman target / log /rmanfs/rmanarc.log append < run {  
allocate channel DISK_2 type disk format '/rmanfs/arc_%T_%u';
##backup archivelog all not backed up 1 times;
backup as compressed backupset ( archivelog all);
}
allocate channel for maintenance device type disk;
delete noprompt obsolete device type disk;
EOF
date >>/rmanfs/rmanarc.log
echo '======stop backup====================================-='>>/rmanfs/rmanarc.log
oracle@ciqdb:~/script>

run {
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO COMPRESSED BACKUPSET;
allocate channel d1 device type disk format 'E:\Oracle\OraData\p6test\backup\full_%U';
allocate channel d2 device type disk format '\\\backup\p6test\full_%U';
backup database tag=full_database_backup;
sql "alter system archive log current";
backup archivelog all not backed up 1 times tag=archivelog_backup;
# we throw away all backups from 40 hours ago. This way we get synchronized with the VM snapshot created at Storage level (meaning, directly using ZFS filesystem commands or from the OS of dedicated storage boxes)
delete noprompt archivelog until time 'sysdate - 3';
delete noprompt backup completed before 'sysdate-40/24';
release channel d1;
release channel d2;

RMAN> delete backupset tag=TAG20181024T085438;

Method 3:
You can also delete backupset those backed up before a particular time:

delete completed before "TO_DATE('Date String','MM/DD/YYYY HH24:MI:SS')";

For example:
delete backup completed before "TO_DATE('09/23/2018 08:00:00','MM/DD/YYYY HH24:MI:SS')";


And also, if backupset file is deleted by OS command, then you can delete related information via RMAN by using "force".
eg:


RMAN> delete force backupset 1;

RMAN> delete force backupset tag=TAG20181024T085438;

RMAN> delete force noprompt backup completed before "TO_DATE('09/23/2018 08:00:00','MM/DD/YYYY HH24:MI:SS')";

你可能感兴趣的:(oracle)