Issuu on Google+

When can I safely delete Archived Redo Logs?

Backup and Recovery Tips

When can I safely delete Archived Redo Logs? Archives are required to roll restored Data Files forward from the time they were backed up to the current time of the rest of the database. If you read that statement carefully enough, you’ll see that it implies that any archives generated from a time earlier than the time a Data File was backed up are not going to be needed to roll it forward, and are hence disposable. The simple rule is, therefore, that whenever a new backup is successfully completed, all archives from a time prior to the start of that backup can be deleted. Note the important qualifier there: it’s the start of the backup that is important. That’s because a Data File is dated by the SCN contained in its header, regardless of what times (i.e., what SCN) actually pertains to the contents of that block. Imagine, for example, that you begin backing up a Data File at 10.00am, and you finish at 10.10am. Oracle will see that entire Data File as being from time 10 o’clock, because that’s what the SCN will tell it –even though different bits of that file might actually be at any one of those ten minutes. If you’d deleted all archives from a time before 10.10am, though, you’d never be able to roll the Data File forward from what it supposes is its time of 10 o’clock, because you can’t skip gaps in the archive sequence. On the other hand, if you’d deleted an archive from time 9.59am, you’d have no trouble performing recovery –because the Data File thinks itself to be older than that, and therefore has no reason to re-perform any of the transactions such an archive would have contained. The same reasoning applies when you consider the database as a whole. It might (for example) take you three hours to backup an entire database, one Data File at a time. You need all the archives from the time that entire backup started –because you can’t guarantee which of the many possible Data Files it contains might be the one that blows up and needs to be restored and recovered. It might be the file that was backed up at 10.00am, or the one at 12.45pm. If you’ve kept all the archives since the time the thing started at 10.00am, however, you’ll have no problem recovering either. The above comments are obviously relevant to hot backups –but they apply equally well to cold backups, too. When you perform a cold backup, you are likely to be copying the entire database at one sitting –and all its constituent Data Files will be at the same SCN, the one issued when you shut the database down. All archives before that time are thus never going to be required to recover any part of the database. But all archives after that time might be. So, in practice, it remains true, even for cold backups, that you need to retain all archives from the time you started to perform the backup onwards.

Copyright © Howard Rogers 2001

24/10/2001

Page 1 of 2


When can I safely delete Archived Redo Logs?

Backup and Recovery Tips

So the specific answer to the question as posed (“when may I safely delete archives?”) is that once a new backup has been successfully been taken, all prior backups and all prior archives may be considered redundant, and can be deleted. Having said all of that, any DBA who merrily deletes all archives (or, come to that, all backups) from a time before the start of the latest complete backup wants his or her head tested. That’s because there’s an important assumption underlying the earlier discussion: that when it comes time to recover a Data File, you actually restore it from the latest complete backup. Ordinarily, of course, that’s exactly what you’d do, because doing so ensures the shortest possible recovery time. But in the real world, accidents happen. Tapes get destroyed. Backups that you’d thought had completed successfully turn out not to have done. Users make requests to recover data deleted several days ago. And so on. In any of those scenarios, you will restore Data Files from a much older backup than the latest complete one, and that will require you to have retained all archives since the time those earlier backups started, if you hope to be able to roll the restored files forward. In the real world, therefore, the actual answer to the question “when may I safely delete archives?” is: “How much insurance do you think you’ll need?”. Or, more prosaically, ‘try to retain as many archives on disk as you possibly can, age them out onto tape when the disk starts getting full, and have a tape rotation such that you can retrieve archives from them going back weeks or even months, depending on how sure you want to be that any recovery scenario can be dealt with’. At one place I worked as the DBA, we used this ‘age out on disk, then onto tape, and rotate’ technique to guarantee that we could restore a Data File from a backup taken up to three months previously. That might be overkill for some, and severe underkill for others, but the principle is sound: bank on strange things happening, and retain archives for as long as storage space permits to deal with them all. In summary: never be too eager to delete old archives. You never know when they may turn out to be useful!

Copyright © Howard Rogers 2001

24/10/2001

Page 2 of 2


What must I backup