Shell script for archive log transfer

hi
I dont want to reinvent the wheel.
I am looking for shell script for log shipping to provide standby db.
What I want to do is, get the last applied archived log number from alert.log
Copy the files from archive destination according to this value.
Cheers

If you don't want to re-invent the wheel you use Dataguard, no scripts.
And your script should use the dictionary, instead of some bs method to read the alert.
v$archived_log has all information!
Also as far as I know, the documentation describes manual standby.
So apparently you not only don't want to reinvent the wheel, but you want the script on a silver plate on your doorstep!
Typical attitude of most DBAs here. Use OTN for a permanent vacation.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Need Help in creating Unix Shell Script for database

    Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
    Here is the condition which i want to implement.
    1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
    2. Increase size of redolog file.
    3. Load sample schema.
    4. dump the schema.
    5. Create empty db (Script should check if db already exists and drop it in this case).
    6. Create backup using rman.
    7. restore backup which you have backed up.

    This isn't much of a "code-sharing" site but a "knowledge-sharing" site.  Code posted me may be from a questioner who has a problem / issue / error with his code.   But we don't generally see people writing entire scripts as responses to such questions as yours.  There may be other sites where you can get coding done "for free".
    What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
    But the expectation here is for you to write your own code.
    Hemant K Chitale

  • Shell script for DB

    Hi,
    I have written shell script for below scenarios, can you please guide me to write this as correct way, requirment is,
    1. i need to connect the database which is on unix server , but before connecting the DB some of the files needs to be removed from \tmp directory.
    2. once removed the script need to connect the database and call the sql file which is in \tmp directory.
    3. the output files will be stored in \tmp directory start with DB name.
    4. finally csv files needs to be transferred to local windows with help of FTP. please find below the script
    #!/bin/sh
    rm -f /tmp/dbmon/DB1*
    CONNSTRING=username/PASSWORD@service
    sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
    EXIT;
    EOF
    HOST='xxxxx'
    USER='xxxxx'
    PASSWD='xxxxxx'
    FILE='E:\STATS\DB1.*'
    cd /tmp/dbmon
    ftp -n -v $HOST << EOT
    user $USER $PASSWD
    prompt
    mput $FILE
    bye
    EOT
    EXIT;
    EOF
    Thanks
    Edited by: ASP on Nov 18, 2011 4:45 PM

    Hi ASP
    It's always a good idea to write entries to timestamped log file without which you will never know where the script went wrong or failed.
    This is not tested but just a small example
    #!/bin/sh
    export LOG_DIR=/tmp/log
    export LOGFILE=$LOG_DIR/`basename $0`_${TIMESTAMP}.log
    if [ ! -d $LOG_DIR ]
    then
         mkdir $LOG_DIR
    fi
    echo "Removing the temporary files from /tmp/dbmon at `date +%Y%m%d_%H:%M:%S`" | tee -a $LOG_FILE
    rm -f /tmp/dbmon/DB1*
    CONNSTRING=username/PASSWORD@service
    echo "Run SQLPlus file" | tee -a $LOG_FILE
    sqlplus -s $CONNSTRING @/tmp/STATS.sql << EOF
    EXIT;
    EOF
    echo "Now FTP the files to windows box " | tee -a $LOG_FILE
    HOST='xxxxx'
    USER='xxxxx'
    PASSWD='xxxxxx'
    cd /tmp/dbmon
    ftp -vn $HOST <<EOF
    quote USER $USER
    quote PASS $PASSWD
    ascii
    cd E:\STATS
    mput DB1.*
    bye
    EOF

  • Shell Script  for Startup and Shutdown the database

    Hi,
    i want Shell Script for Startup and Shutdown the database in Solaries.
    could any one can hep me where i can get this script. or send to me to [email protected]
    Thanks & Regards,
    Gangi reddy

    SHUTDOWN
    SHUTDOWN ABORT]
    Shuts down a currently running Oracle instance, optionally closing and dismounting a database.
    Terms
    Refer to the following list for a description of each term or clause:
    ABORT
    Proceeds with the fastest possible shutdown of the database without waiting for calls to complete or users to disconnect.
    Uncommitted transactions are not rolled back. Client SQL statements currently being processed are terminated. All users currently connected to the database are implicitly disconnected and the next database startup will require instance recovery.
    You must use this option if a background process terminates abnormally.
    IMMEDIATE
    Does not wait for current calls to complete or users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    NORMAL
    NORMAL is the default option which waits for users to disconnect from the database.
    Further connects are prohibited. The database is closed and dismounted. The instance is shutdown and no instance recovery is required on the next database startup.
    TRANSACTIONAL [LOCAL]
    Performs a planned shutdown of an instance while allowing active transactions to complete first. It prevents clients from losing work without requiring all users to log off.
    No client can start a new transaction on this instance. Attempting to start a new transaction results in disconnection. After completion of all transactions, any client still connected to the instance is disconnected. Now the instance shuts down just as it would if a SHUTDOWN IMMEDIATE statement was submitted. The next startup of the database will not require any instance recovery procedures.
    The LOCAL mode specifies a transactional shutdown on the local instance only, so that it only waits on local transactions to complete, not all transactions. This is useful, for example, for scheduled outage maintenance.
    Usage
    SHUTDOWN with no arguments is equivalent to SHUTDOWN NORMAL.
    You must be connected to a database as SYSOPER, or SYSDBA. You cannot connect via a multi-threaded server. For more information about connecting to a database, see the CONNECT command earlier in this chapter.
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1013607
    Joel Pérez

  • How to calculate storage space for archive log files and database backups?

    Hi all,
    I have a 1.8 terabyte Oracle 9i database and need to plan for how much additional disk space I will need to perform nightly backups and for archivelog files. Is there a script or formula available that can help me estimate how much required disk space I will need to hold a days worth of archived logs as well as a nightly export dump file and a full hot RMAN backup on disk?
    Thanks!

    I'm not sure how to estimate the size of your backups, especially if you use incrementals. However, the space required for archive logs will be equal to the amount of REDO your DB generates. I would count the number of log switches per day with a query like the following:
    select trunc(first_time), count(*)
    from v$log_history
    group by trunc(first_time)
    I would then take the average and multiply this count by the size of your redo log files (assuming they are all the same size).

  • Validation failed for archived log

    Hi,
    oracle database version 11.2.0.4
    OS centOS 6.5
    Recently i have set rman backup scripy on production Database, As we are using dbvisit for standby database for that we have set cron which run in every 10 minutes  it generates archive and copy it to standby side,
    but sometimes backup failed due to expected archive is not represent at location so i put "crosscheck archivelog all" in script now backup is running fine, But i have analyzed backlog file getting
    "validation failed for archived log" the time stamp i have checked validation failed archive is current day and yesterday even though archives are present at the location and CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
    Guys i am worried it shouldn't be a big issue for me,
    please suggest what is wrong

    This forum is for Berkeley DB high availability. We do not have the expertise to help you with your Oracle database 11.2.0.4 issue. You'll need to submit this question to one of the Oracle database forums to get the help you are looking for.
    Paula Bingham

  • Shell script for creating,altering, etc ., a database

    hi there,
    Please help me to find shell scripts for creating,altering, etc a database..
    Thanks & Regards,
    Balu.

    Thanks to all , but dbca generates XML files :
    <DatabaseTemplate name="MYDB" description="" version="10.2.0.0.0">
       <CommonAttributes>
          <option name="ISEARCH" value="false"/>
          <option name="OMS" value="false"/>
          <option name="JSERVER" value="true"/>
          <option name="SPATIAL" value="true"/>
          <option name="ODM" value="true">
             <tablespace id="SYSAUX"/>
          </option>
          <option name="IMEDIA" value="true"/>
          <option name="XDB_PROTOCOLS" value="true">
             <tablespace id="SYSAUX"/>
    ..................I need a file.sql script to launch in sqlplus. Something like the following :
    CREATE DATABASE MYDB
    USER SYS IDENTIFIED BY ***
    USER SYSTEM IDENTIFIED BY ***
    LOGFILE GROUP 1 ('/home/oracle/oracle/instances/oradata/MYDB/redo1/redo01.log') SIZE 15M,
    GROUP 2 ('/home/oracle/oracle/instances/oradata/MYDB/redo2/redo02.log') SIZE 15M,
    GROUP 3 ('/home/oracle/oracle/instances/oradata/MYDB/redo3/redo03.log') SIZE 15M
    ......................

  • Shell script for below pl/sql script dbms_file_transfer

    Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
    I have trasfer the files from asm into filesystem .
    it is working . but i have to put in the loop
    begin
    dbms_file_transfer.copy_file(
    source_directory_object => 'src',
    source_file_name => 'ncsn',
    destination_directory_object => 'dest',
    destination_file_name => 'ncsn');
    end;
    Edited by: user8680248 on 27/10/2009 20:55

    user8680248 wrote:
    Please let me know how tt write the shell script for below pl/sql script dbms_file_transfer it is
    I have trasfer the files from asm into filesystem .
    it is working . but i have to put in the loop
    begin
    dbms_file_transfer.copy_file(
    source_directory_object => 'src',
    source_file_name => 'ncsn',
    destination_directory_object => 'dest',
    destination_file_name => 'ncsn');
    end;What database version?
    What are you trying to do exactly?
    It's working but you have to put it in a loop. Fine, what's the problem you are having?
    begin
      loop
        exit when ... whatever the exit condition is ...
        dbms_file_transfer.copy_file(
          source_directory_object => 'src',
          source_file_name => 'ncsn',
          destination_directory_object => 'dest',
          destination_file_name => 'ncsn');
      end loop;
    end;

  • Shell script for export backup in oracle 11g

    Hi,
    Oracle version 11.2.0..
    O/S-AIX
    How to write shell script for export full backup in oracle 11g and also need to remove 2 days of old backup.
    Regards,
    Raju

    How to write shell script for export full backup in oracle 11g
    Do you mean that export is your backup strategy ? is your database running in noarchivelog mode ? if so, then why ? if not so, then why not RMAN ?
    need to remove 2 days of old backup.
    If that mean remove files older than 2 days, you can use something like this :
    $ find <absolute directory path> -mtime +2 -exec rm {} \;

  • Shell script for batch compilation of forms 10g on AIX 5.3L AS

    Hi All,
    Can anybody provide me the Shell script for batch compilation of forms 10g and reports 10g on AIX 5.3L AS?
    Regards,
    SAM

    Hi Alex,
    I tried with the below script as well as the one you had posted.
    ORACLE_HOME=/opt/oracle/OraHome_3
    export ORACLE_HOME
    TNS_ADMIN=$ORACLE_HOME/network/admin
    export TNS_ADMIN
    LIBPATH=$ORACLE_HOME/lib32:$ORACLE_HOME/jdk/jre/bin:$ORACLE_HOME/jdk/jre/bin/cla
    ssic:$LIBPATH
    export LIBPATH
    cd ../forms
    for i in `ls *.pll`
    do
    echo Compiling Library $i ....
    $ORACLE_HOME/bin/frmcmp module=$i userid=mydbuser/mydbuser@mydb
    batch=yes module_type=library
    compile_all=yes window_state=minimize
    done
    export ORACLE_HOME=/opt/oracle/OraHome_3
    export ORACLE_TERM=vt220
    export LD_LIBRARY_PATH=/opt/oracle/OraHome_3/lib:/opt/oracle/OraHome_3/jdk/jre/l
    ib:/opt/oracle/OraHome_3/jdk/jre/lib/i386:
    cd ../forms
    for i in `ls *.pll`
    do
    echo "Compiling Library $i ...."
    /opt/oracle/OraHome_3/bin/frmcmp module_type=form userid=mydbuser/mydbuser@mydb
    module=$i batch=yes compile_all=no
    window_state=minimize upgrade=no
    done
    echo "PLL Compilation done"
    But there was a same kind of error thst turning up all the time.
    Compiling Library Agf.pll ....
    Forms 10.1 (Form Compiler) Version 10.1.2.0.2 (Production)
    Forms 10.1 (Form Compiler): Release - Production
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    PL/SQL Version 10.1.0.4.2 (Production)
    Oracle Procedure Builder V10.1.2.0.2 - Production
    Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
    Oracle Multimedia Version 10.1.2.0.2 (Production)
    Oracle Tools Integration Version 10.1.2.0.2 (Production)
    Oracle Tools Common Area Version 10.1.2.0.2
    Oracle CORE 10.1.0.4.0 Production
    FRM-10043: Cannot open file.
    Form not created
    I hence updated the permissions on the pll as below
    -rwxrwxrwx 1 oracle oinstall 335872 May 19 16:31 Agf.pll
    But the problem is still persisting.
    My environment details are as below.
    I am working on Win XP machine. Connected to my AS via telnet and xmanager. I have set my DISPLAY to my local IP.
    Is there any thing more that I need to do? If so then let me know.
    Regards,
    SAM

  • Shell script for DB backup

    HI,
    i have written some java code Database backup but there are some problems with that so now i need to write shell script for db backup.
    what i was doing in java code i was running command like that
    /usr/local/bin/tar cvzf /export/home/monitor/FILE_20091005.tar.gz FILES/*20091005.*which compress the all *20091005* files (myisam table files)
    but after compression file doesn't extract
    so i have to write shell script for that ..... can any body guide me how can i write that kind of script and put it in cron job.
    thanks

    soundar wrote:
    Hi all,
    I have migrated database from 8i to 10gr2.For Backup in 8i, we used a RMAN shell script (scheduled uding cron tab) to backup the database to Tape.(VERITAS BACKUP).
    I am new to 10G.I checked out the options to backup the database using Oracle Enterprise manager DB console.
    http://www.oracle.com/technology/obe/10gr2_db_single/ha/rman/rman_otn.htm#t1d
    I am planning to take a test backup using the steps mentioned inthe above url.Could any one suggest whcih is the best option for database backup,eiether to use Oracle Enterprise manager DB console or thru RMAN shell script for backup..?
    Edited by: soundar on Mar 9, 2010 10:53 PMDear soudar
    I woudn't suggest you to work with EM if you want to be a professional DBA. Start learning RMAN and use CLI instead of GUI
    Those who live by the GUI, die by the GUI

  • "recover database until cancel" asks for archive log file that do not exist

    Hello,
    Oracle Release : Oracle 10.2.0.2.0
    Last week we performed, a restore and then an Oracle recovery using the recover database until cancel command. (we didn't use backup control files) .It worked fine and we able to restart the SAP instances. However, I still have questions about Oracle behaviour using this command.
    First we restored, an online backup.
    We tried to restart the database, but got ORA-01113,ORA-01110 errors :
    sr3usr.data1 needed media recovery.
    Then we performed the recovery :
    According Oracel documentation, "recover database until cancel recovery" proceeds by prompting you with the suggested filenames of archived redo log files.
    The probleme is it  prompts for archive log file that do not exist.
    As you can see below, it asked for SMAarch1_10420_610186861.dbf that has never been created. Therefore, I cancelled manually the recovery, and restarted the database. We never got the message "media recovery complete"
    ORA-279 signalled during: ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10417_61018686
    Fri Sep  7 14:09:45 2007
    ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10418_610186861.dbf'
    Fri Sep  7 14:09:45 2007
    Media Recovery Log /oracle/SMA/oraarch/SMAarch1_10418_610186861.dbf
    ORA-279 signalled during: ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10418_61018686
    Fri Sep  7 14:10:03 2007
    ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10419_610186861.dbf'
    Fri Sep  7 14:10:03 2007
    Media Recovery Log /oracle/SMA/oraarch/SMAarch1_10419_610186861.dbf
    ORA-279 signalled during: ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10419_61018686
    Fri Sep  7 14:10:13 2007
    ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10420_610186861.dbf'
    Fri Sep  7 14:10:13 2007
    Media Recovery Log /oracle/SMA/oraarch/SMAarch1_10420_610186861.dbf
    Errors with log /oracle/SMA/oraarch/SMAarch1_10420_610186861.dbf
    ORA-308 signalled during: ALTER DATABASE RECOVER    LOGFILE '/oracle/SMA/oraarch/SMAarch1_10420_61018686
    Fri Sep  7 14:15:19 2007
    ALTER DATABASE RECOVER CANCEL
    Fri Sep  7 14:15:20 2007
    ORA-1013 signalled during: ALTER DATABASE RECOVER CANCEL ...
    Fri Sep  7 14:15:40 2007
    Shutting down instance: further logons disabled
    When restaring the database we could see that, a recovery of online redo log has been performed automatically, is it the normal behaviour of a recovery using "recover database until cancel"  command ?
    Started redo application at
    Thread 1: logseq 10416, block 482
    Fri Sep  7 14:24:55 2007
    Recovery of Online Redo Log: Thread 1 Group 4 Seq 10416 Reading mem 0
      Mem# 0 errs 0: /oracle/SMA/origlogB/log_g14m1.dbf
      Mem# 1 errs 0: /oracle/SMA/mirrlogB/log_g14m2.dbf
    Fri Sep  7 14:24:55 2007
    Completed redo application
    Fri Sep  7 14:24:55 2007
    Completed crash recovery at
    Thread 1: logseq 10416, block 525, scn 105140074
    0 data blocks read, 0 data blocks written, 43 redo blocks read
    Thank you very much for your help.
    Frod.

    Hi,
    Let me answer your query.
    =======================
    Your question: While performing the recovery, is it possible to locate which online redolog is needed, and then to apply the changes in these logs
    1.   When you have current controlfile and need complete data (no data loss),
          then do not go for until cancel recovery.
    2.   Oracle will apply all the redologs (including current redolog) while recovery
         process is    on.
    3.  During the recovery you need to have all the redologs which are listed in the    view    V$RECOVERY_LOG and all the unarchived and current redolog. By querying  V$RECOVERY_LOG  you    can find out about the redologs required.
    4. If the required sequence is not there in the archive destination, and if recovery process    asks for that sequence you can query V$LOG to see whether requested sequence is part of the    online redologs. If yes you can mention the path of the online redolog to complete the recovery.
    Hope this information helps.
    Regards,
    Madhukar

  • How can I set destination for archived logs?

    I would like to know:
    how to set destination for archived logs?
    how to identify the init.ora that is used for my database?
    With rman using compressed backupset by default and and making
    backup database;
    What does it backup exactly?

    Another thing I am wondering, when I make a backup with rman : backup database.
    It saves the backups in the directory autobackup from the flash_recovery_area but it seems that it only saves the data files and the control files.Isn't there a way to sava archived logs files, control files, datafiles in a single backup?
    In fact I would like to make a full backup using rman on sunday of everything and a incremental backup all days of the week how can I acomplish this with a retention of 7 days?

  • Secondary destination for Archived logs

    Version: 10.2, 11.1, 11.2
    We occasionally get 'archiver error' on our production DBs due to our LOG_ARCHIVE_DEST_1 being full. How can I have a secondary location for archive logs in case my 'primary' location (LOG_ARCHIVE_DEST_1) becomes full ?
    I gather that LOG_ARCHIVE_DEST_2 is reserved for shipping archive logs to Dataguard standby DB in which you specify the tns entry of standby using SERVICE parameter.
    Can I specify LOG_ARCHIVE_DEST_3 as my secondary location in case LOG_ARCHIVE_DEST_1 becomes full ? Is it what LOG_ARCHIVE_DEST_n meant for ? Although the documentation says you can have upto 10 locations, I am confused if they are meant to store Multiplexed copies of archive logs ? That is not what I am looking for ?

    >
    Hi again Tom,
    I have one more question:
    ALTER SYSTEM SET LOG_ARCHIVE_DEST_4 = 'LOCATION=/disk4/arch';
    ALTER SYSTEM SET LOG_ARCHIVE_DEST_3 = 'LOCATION=/disk3/arch
        ALTERNATE=LOG_ARCHIVE_DEST_4';
    ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_4=ALTERNATE;
    SQL> SELECT dest_name, status, destination FROM v$archive_dest;
    DEST_NAME               STATUS    DESTINATION
    LOG_ARCHIVE_DEST_1      VALID     /disk1/arch     -------------> Dest1
    LOG_ARCHIVE_DEST_2      VALID     +RECOVERY       -------------> Dest2
    LOG_ARCHIVE_DEST_3      VALID     /disk3/arch     -------------> Dest3
    LOG_ARCHIVE_DEST_4      ALTERNATE /disk4/archMy understanding is (and I'm not terribly sure at the minute - don't have a test system to hand. I haven't
    set up a backup/recovery strategy in a while - I just restore backups from time to time (normally every 4 weeks)
    to ensure that the database recovers as it should) - my understanding is that under the scheme above
    DEST_3 will be a copy of what's in DEST_1. DEST_4 on the other hand will "step in" should DEST_1
    or DEST_3 fill up/fail.
    As to DEST_2, I'm not sure - maybe something to do with Fast Recovery Area? I've Googled but can't
    find anything - the trouble is that all the pages about this contain the word "recovery" and the "+"
    sign doesn't appear to affect the search - does "+" mean something special to Google?
    I don't have a system at the moment - if you do, why don't you test and see? On a test system, fill
    up the file system for DEST_1 with rubbish and check to see what happens?
    All of the above is to be taken with a pinch of salt - I don't have a system to hand and am not certain,
    so CAVEAT EMPTOR
    HTH,
    Paul...
    Edited by: Paulie on 21-Jul-2012 17:20

  • Shell scripting for sql queires

    Hi All,
    I have written 4 sql queires.now i want to write shell scripting for this.so please guide me in this issue..
    1. select * from emp;
    2. select * from dept;
    3. delete from emp;
    4. delete from dept;
    Thank you.

    Hi,
    Apologees for the c!=k!=b stuff. I guess it was to cryptic. It means
    C shell is not equal to Korne shell and both are not equal to Bourne shell.
    I can't provide you with any site for such stuff. Maybe Google might help? Or someone who is a nicer guy than me...

Maybe you are looking for

  • Easiest Question - Should I use some BI Object?

    This potentially is the easiest question here. Before I spend tons of time and effort learning BI to see if I can do something, I thought I'd just throw out a query here. I'm creating an Interactive Form that the user will fill out, when they are fin

  • CM01, 02, 03 and 04 List Selection in Overall Profile

    Does anyone know how to create a List Profile for CM01 u2026 CM4 to include in an evaluation profile so that when a user gets in the transaction, they see the predefined set of data? I already have an overall profile and an evaluation profile. Thanks

  • How to get latest Idoc no.

    Hi, I need to get the latest Idoc no created in the system. I do understand that in production enviromnet an idoc can be generated every second. Please can anybody suggest me any way to get the latest idoc no. <REMOVED BY MODERATOR> Thanks. Aafaque H

  • Volume bar missing

    Help.. my volume bar, name of music and progress bar are gone. When I listen to music, my new video iPod screen is blank. When I click menu, it goes back to the list of songs (yea.. the screen is not always blank).

  • The new altogether BT web page

    Trying to login to the new altogether BT'S new web page. Can't get passed the enter mobile phone bit, left it blank because I don't have a mobile phone. Does that mean I can never access my online details?!!