0

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.

  • Are they full or incremental backups? It makes a difference – Philᵀᴹ Nov 14 at 12:27
  • @Philᵀᴹ full backup. – neworacler Nov 14 at 12:28
0

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.

  • Hi sir, thank you for your answer. Yes, it will backing up control files, spfile and also archivelogs. And can I use "delete obsolete redundancy 2;" ? – neworacler Nov 14 at 12:37
  • @neworacler: Keep things simple (for yourself). Define the retention policies and just let RMAN apply them. For example, with the retention policy configured, you just execute "delete obsolete". RMAN will work out what it can and can't get rid of. Also, to change your policy, you only have to reconfigure it in RMAN; all your scripts will adopt it. If you code the retention policies into your scripts, you have to change all of them whenever you change the policy. – Phill W. Nov 14 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.