DOS batchscript to move archivelog files by date
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: DOS batchscript to move archivelog files by date

  1. #1
    Join Date
    May 2003
    Posts
    10

    DOS batchscript to move archivelog files by date

    Hello,

    Does anyone have a DOS batchscript for use on windows2000 to move (or copy) archive logfiles that are older than, let's say 2 days from now, to another directory? Or does anybody know a good site where I can find stuff like that?

    Thanks in advance,

    Jean-Paul

  2. #2
    Join Date
    Sep 2002
    Posts
    411
    one way I could think of is a small program to copy those files to another location and delete them from the old location right after you had moved those files and use scheduler Tasks to schedule the script to run every 2 days

  3. #3
    Join Date
    Jan 2001
    Posts
    3,131
    I believe Veritas has an Oracle agent that does this as well. Might be a little safer, I'm not sure.

    MH
    I remember when this place was cool.

  4. #4
    Join Date
    Jun 2001
    Posts
    40
    RMAN can backup your archivelogs to disk in it's own proprietary format, and use a retention policy to delete archivelogs older than x days.

  5. #5
    Join Date
    Nov 2000
    Posts
    440
    Here's a way to delete your archive logs files automaticaly.
    This script delete archive logs that have more than 30 days.
    It is very useful when you need the disk space.
    Of course, make sure that you have valid backups,
    cuse you could delete archive that you need.


    First, i give grant to objects owned by the user sys.
    Then, i create a directory to use the bfilename function.
    After, i create a procedure that extract the name of the archive
    and one that finds old archive logs and delete them.


    You can execute that procedure manualy, or create a job that will execute
    that procedure periodicaly.

    ---------------------------------------------------------------------------------------
    connect sys/YOUR_SYS_PASSWORD


    grant select on v_$archived_log to YOUR_USER;
    grant execute on dbms_backup_restore to YOUR_USER;


    connect YOUR_USER/USER_PASSWORD

    create or replace directory ARCHIVEDIR as 'd:\ora8i\orant\oradata\archive';

    create or replace function proc_nom_fich(P_chain IN Varchar2) return varchar2 IS
    l_posi number;
    l_nom_fich varchar2(100);

    begin
    l_posi := length(P_chain);
    loop
    if substr(P_chain,l_posi,1) in ('/','\') then
    l_nom_fich := substr(P_chain,l_posi + 1);
    exit;
    else
    l_posi := l_posi - 1;
    if l_posi < 0 then
    exit;
    end if;
    end if;
    end loop;

    return(l_nom_fich);
    end;
    /

    create or replace procedure proc_dele_arch_log is
    arch_file bfile;
    arch_exis boolean;
    arch_file_name varchar2(100);

    cursor sel_archive is
    select name
    from v$archived_log
    where completion_time < sysdate - 30;

    begin
    for list in sel_archive loop
    arch_exis := FALSE;
    arch_file_name := proc_nom_fich(list.name);
    arch_file := bfilename('ARCHIVEDIR',arch_file_name);
    arch_exis := dbms_lob.fileexists(arch_file) = 1;

    if arch_exis then
    sys.dbms_backup_restore.deleteFile(list.name);
    end if;
    end loop;
    end;
    /


    ---------------------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width