Hi all!
Sometimes you are caught in a situation where your database is not backuping archivelogs and need to generate a quick backup commands for those are not backuped yet and deleting it, right?
I saw this situation in this archived discussion at OTN. Unfortunately I couldn’t give my answer… But it’s how I do:
select 'backup archivelog from sequence '||sequence#||' until sequence '||sequence#||' thread '||thread#||' filesperset=1 delete input;',first_time from v$archived_log where backup_count=0 and name is not null order by first_time desc;
It generates an output like:
greporadb> select 2 'backup archivelog from sequence '||sequence#||' until sequence '||sequence#||' thread '||thread#||' filesperset=1 delete input;',first_time 3 from v$archived_log where backup_count=0 and name is not null 4 order by first_time desc; 'BACKUPARCHIVELOGFROMSEQUEN -------------------------------------------------------------------------------------------------------------------------------------------------------------------- backup archivelog from sequence 152153 until sequence 152153 thread 1 filesperset=1 delete input; backup archivelog from sequence 152152 until sequence 152152 thread 1 filesperset=1 delete input; backup archivelog from sequence 152151 until sequence 152151 thread 1 filesperset=1 delete input; 3 rows selected.
And be happy!
But an observation! It not works this way for databases with dataguard. For these cases you’ll need to add “and name’&dgname’” at select where clause… 😉
See ya!
Matheus.
The Smart lazy 🙂
Nice!