Forum Stats

  • 3,825,902 Users
  • 2,260,573 Discussions
  • 7,896,727 Comments

Discussions

When and how to delete archive logs

3817829
3817829 Member Posts: 2
edited Jan 20, 2019 4:41AM in Recovery Manager (RMAN)

Hi Guys,

We are still not go live with our production database and we have enabled achieve logs on this database.

Since archive logs are building up in numbers, we may have space related issue.

What I know:

archive logs help us to do a Point in time recovery. Also after enabling archive log one can take a consistent backup of database without downtime.

What I don't know:

1. Since we are taking daily full backup. Can I safely delete archive logs through rman which were created before this backup. Can i get command for this.

2. Also can i get rman command to safely delete the archive logs that are older then 2 days.?

3. What should be my approach so that I can have archive logs related to at least last 2 full backups.

Marshall Pyle
«1

Answers

  • top.gun
    top.gun Member Posts: 3,666 Gold Crown
    edited Dec 28, 2018 5:31AM

    1. You can delete the archivelogs already backed up, or if you are using the FRA for the archivelogs, the FRA will autodelete the backed up archivelogs for you when the FRA fills.

    2&3. You need to set the backup policy to redundancy of 2. You can then let the FRA delete the archivelogs and backups that you don't need.

  • BrunoVroman
    BrunoVroman Member Posts: 1,848 Silver Crown
    edited Dec 28, 2018 6:02AM

    Hello 3817829,

    I strongly suggest that you have a test system with same configuration as the prod system. Practice / learn / play in test before setting up something in prod.

    Have a look at incremental backups  (L0 and L1) and "block_change_tracking", include the deletion of archives in the RMAN scripts (perform several ARCHIVE backups during the day), look at the Oracle documentation for explanations and examples.

    Something else: may I suggest you to modify your "display name" to something more human-friendly? You are not a number! Please have a look at

    Best regards,

    Bruno Vroman.

    P.S.: Season's greetings, Oracle-mathematical way

  • Phill W.
    Phill W. Member Posts: 36 Silver Badge
    edited Dec 28, 2018 11:27AM

    > "... archive logs help us to do a Point in time recovery."

    Archivelogs are essential for Point in Time Recovery.

    > "... after enabling archive log one can take a consistent backup of database without downtime."

    Strictly speaking, the data files saved during any "hot" backup are inconsistent - but can be made so through the application of Archivelogs.

    But, as happens all too frequently, we're discussing Backups when, of course, we should be discussing Recovery, which is the whole point of any of this.

    If your production database goes Bang!, how quickly do you need to get it back and how much data are you prepared to lose in the doing so?

    If you only want to get to the last "full" backup or some time thereafter, then yes, you can get rid of archivelogs saved before the last L0 backup.

    > "Since we are taking daily full backup. Can I safely delete archive logs through rman which were created before this backup. Can i get command for this."

    Probably.  Most likely, you're taking a Level 0 backup to which you can apply redo logs.  In that case, you could remove any archivelogs backed up before that L0 was taken, as long as you only want to get back as far as that last L0 backup.  You might need the option to go back further than that and such a requirement would come out of your Recovery Strategy.  BTW, that's not for you to create out of thin air - it has to come from your organisation.

    > "Also can i get rman command to safely delete the archive logs that are older then 2 days.?"

    That one's straightforward:

    delete [noprompt] archivelog until time 'sysdate-2' ;

    RMAN will also ensure (assuming you define the archivelog deletion policy correctly) that it doesn't get rid of anything it might need to do a Recovery.

    > "What should be my approach so that I can have archive logs related to at least last 2 full backups."

    I would strongly recommend using a "recovery window". 

    Tell RMAN that you want to be able to recover back to, say, two days ago and it will make sure it keep holds of everything it needs to do so.  Of course, assuming that you run the backup and delete scripts daily, RMAN will accumulate almost three days worth of "stuff" before the scripts clear them down again.

    Realistically, you should not allow disk space issues to constrain your Recovery options.

    Get your employers to pay for the disk space to make this work (the way they want it to, as per the Recovery Strategy).  Do not wait and try apologising when you can't get the database back even if it was because they didn't provide enough space for you to do your job properly.

  • Mr. C
    Mr. C Member Posts: 35 Blue Ribbon
    edited Jan 7, 2019 9:43AM

    > 1. Since we are taking daily full backup. Can I safely delete archive logs

    > through rman which were created before this backup.

    What about testing it ? Obviously, don't remove production files, without having copies.

  • Mark D Powell
    Mark D Powell Member Posts: 5,914 Blue Diamond
    edited Jan 7, 2019 11:13AM

    user3817829, always identify the full Oracle version in use.

    - -

    As Phil pointed out hot backups, normal rman backups, are inconsistent which is why the associated archived redo log files or backups are required so that the restored database data files can be made consistent to a point in time, hopefully, the point in time of the media failure.

    - -

    I like the idea of keeping all the archived redo log backups to support recovery from the prior backup till now.  That way if the most recent backup should prove corrupt or get accidentally removed you would have a prior backup from which to attempt recovery,

    - -

    You should set your backup retention policies based on your needs, after reviewing the documentation topic: Configuring the Backup Retention Policy

    https://docs.oracle.com/database/121/BRADV/rcmconfb.htm#BRADV89436

    - -

    If the account wants the ability to be able to restore specific pre-identified points in time like year-end or quarter-end versions of the database then look at the PLUS ARCHIVE log option to include the archived redo logs necessary to bring a backup consistent to be included as part of the backup set.

    - -

    HTH -- Mark D Powell

  • Joerg.Sobottka
    Joerg.Sobottka Senior Consultant and Oracle Ace Member Posts: 597 Bronze Trophy
    edited Jan 7, 2019 12:24PM

    To be sure that the archivelogs are in a backup you can delete them with a clause:

    delete archivelog all completed before 'sysdate-2'  BACKED UP 2 TIMES to disk;

  • 3817829
    3817829 Member Posts: 2
    edited Jan 7, 2019 11:13PM

    Thanks for your answer Phill.

    In my full backup rman script. how do i tell rman to backup all archive log since last full backup as I don't want all the archive logs backup since the beginning.

    Also since we are taking 2 hourly backup of all archive logs only.

  • EdStevens-OC
    EdStevens-OC Member Posts: 55 Silver Trophy
    edited Jan 8, 2019 7:46AM
    3817829 wrote:Thanks for your answer Phill.In my full backup rman script. how do i tell rman to backup all archive log since last full backup as I don't want all the archive logs backup since the beginning.Also since we are taking 2 hourly backup of all archive logs only.

    Look at Joerg.Sobottka's response #6.

    Also, your backup scripts should include 'delete noprompt obsolete;'  That will delete all backupsets that are no longer needed to enforce your recovery window.  IF you are using the FRA, then obsolete backups will automatically get deleted as needed (and as possible) to free up disk space, but I'm old school and do my own housekeeping.

  • Joerg.Sobottka
    Joerg.Sobottka Senior Consultant and Oracle Ace Member Posts: 597 Bronze Trophy
    edited Jan 8, 2019 3:32PM
    3817829 wrote:Thanks for your answer Phill.In my full backup rman script. how do i tell rman to backup all archive log since last full backup as I don't want all the archive logs backup since the beginning.Also since we are taking 2 hourly backup of all archive logs only.

    You are doing archive log backups every 2 hours? Of all archive logs? You shouldn't do that, also you shouldn't specify to backup the archivelogs from the last (successful/unsuccesful) full backup.

    Take 2 copies of archivelogs, independently of your full backups and keep them until the time window you want them to be able to recover ends.

    Like with the delete, you can backup archivelogs all not backed up 2 times.

  • Marshall Pyle
    Marshall Pyle Member Posts: 16 Bronze Trophy
    edited Jan 8, 2019 3:58PM

    Hi,

    It might help to define what your long term database backup strategy will be and start composing the methods to reach those requirements now so you are ready to go when the database becomes production.

    Thanks,

    Marshall

    User_OU04L