سؤال

I'm using crontab for automatic backup (full backup). It works 2 times in a day (8 AM and 23 PM). In my script I use delete obsolete but I have a question. I want to delete old backups without last 2 backup. Let's say:

Day 1: 8 AM

Day 1: 23 PM

Day 2: 8 AM (When my script run here and complete backup operation, after that my delete command should delete just Day 1: 8 AM backup)

How can I do it with delete obsolete command?

It's my script:

#!/bin/bash
. /home/oracle/.bash_profile
RMANBACKUP_MOUNTPOINT1=/u01/backup/rman/
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_DATE_FORMAT="YYYY-MM-DD:HH24:MI:SS"
rman target /  LOG '/oracle/backups/log/rman.log' << EOF
run{
allocate channel ch1 device type disk MAXPIECESIZE 200M;
allocate channel ch2 device type disk MAXPIECESIZE 200M;
backup spfile;
backup current controlfile;
backup database format '%d_%T_db' plus archivelog format '%d_%T_arch';
delete obsolete redundancy 2;
}
exit;
EOF

Thank you.

هل كانت مفيدة؟

المحلول

Tell RMAN what you want/need to keep and let it do the worrying.

CONFIGURE RETENTION POLICY TO REDUNDANCY 2 ; 

That will keep two copies of your database and consider anything before that as obsolete.

I am a little concerned that you say you're only taking "full backups".

Are you backing up the ControlFiles? The ArchiveLogs?
Without the former, you may have problems restoring a database after changing its structure (removing or even adding DataFiles) and without the latter, you lose any ability to perform a Point-in-Time Recovery.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى dba.stackexchange
scroll top