Cold backup shell scripts

Could anyone please send me Shell script for taking Cold backups on solaris
The script will be run and will start taking backup
if possible Automatically it will Down and UP the Database
Thanks
Mark

I'm sure that a short google search should find some example for you.
Here some scripts :
http://orafaq.com/scripts/
http://www.dbasupport.com/oracle/scripts/Backup_Recovery/
But, that would be better to google for more results :
http://www.google.fr/search?q=oracle+script+backup&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:fr:official
Nicolas.

Similar Messages

  • My cold backup shell script not working

    I have written a shell script for cold backup but. It says that line 42 has unexpected syntex error '{' and line 57 unexpected end of file. Please help
    BKUP_DIR=/u03/backups/abu/nightly_backup
    LOG_FILE=/u03/backups/abu/backup.log
    ORACLE_HOME= /u01/app/oracle/product/10.2; export ORACLE_HOME
    ORACLE_SID=SEED; export ORACLE_SID
    PATH="$PATH:$ORACLE_HOME/bin";export PATH
    # Execute the backup procedure
    echo ymd=`date +%Y%m%d` >> $LOG_FILE
    echo "Database BACKUP starting." >> $LOG_FILE
    ORACLE_HOME=/u01/app/oracle/product/10.2; export ORACLE_HOME
    ORACLE_SID=SEED; export ORACLE_SID
    PATH="$PATH:$ORACLE_HOME/bin";export PATH
    rman target=/ << EOF
    shutdown immediate
    EOF
    if [ $? -eq 0 ]
    then
    mkdir -p ${BKUP_DIR} # make directory
    echo "Database shut down.">> $LOG_FILE
    else echo "not shutdown".>> $LOG_FILE
    fi
    if [ ! -d ${BKUP_DIR} ]
    then
    echo "Not a directory: ${BKUP_DIR}">> $LOG_FILE
    exit 1
    fi
    echo "Previous Backup is being removed." >> $LOG_FILE
    rm ${BKUP_DIR}/${ymd-${seed}.gz >>$LOG_FILE
    echo "Cold backup being performed." >> $LOG_FILE
    cp /u01/app/oracle/admin/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gz #copying database files into new dir
    cp /u02/oradata/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gz
    cp /u03/oradata/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gz
    echo "Cold backup of archive logs being performed." >> $LOG_FILE
    mv /u01/app/oracle/product/10.2/dbs/arch/* ${BKUP_DIR}/$ymd-${cmsv}.gz
    gzip ${BKUP_DIR}/$ymd-${cmsv}
    echo "Restarting Database" >> $LOG_FILE
    rman target=/ << EOF
    startup
    EOF
    else
    echo "Database will NOT start up." >> $LOG_FILE
    fi
    echo 'ymd='date +%Y%m%d' >> $LOG_FILE
    echo "Database BACKUP has completed." >> $LOG_FILE
    exit

    I trying to write that script for our new production database. My script will create a folder automatically and will copy all database files into the folder. Now my script dont copy the files into the direcory that automatically create. I want my directory name with timestamp that i already speciy in my code. The scripts now generate an error that now such files or directory. I mean when it tries to copy files from source to destination folder. Please give me some suggestions.
    if [ $? -eq 0 ]
    then
    mkdir -p ${BKUP_DIR} # make directory
    echo "Database shut down.">> $LOG_FILE
    else echo "not shutdown".>> $LOG_FILE
    fi
    if [ ! -d ${BKUP_DIR} ]
    then
    echo "Not a directory: ${BKUP_DIR}">> $LOG_FILE
    exit 1
    fi
    echo "Previous Backup is being removed." >> $LOG_FILE
    rm ${BKUP_DIR}/${ymd-${seed}.gz >>$LOG_FILE
    echo "Cold backup being performed." >> $LOG_FILE
    cp /u01/app/oracle/admin/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gz #copying database files into new dir
    cp /u02/oradata/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gz
    cp /u03/oradata/SEED/* ${BKUP_DIR}/$ymd-${cmsv}.gzecho "Cold backup of archive logs being performed." >> $LOG_FILE

  • RMAN backup shell script

    Hi,
    I am trying to setup incremental backup shell script to run anutomatic every night. I am getting below errors when I run script. What am I missing here?
    oradev]/home/oradev ./RMAN_DEV_incr1.sh
    RMAN> exit
    ./RMAN_DEV_incr1.sh[13]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[14]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[15]: CONFIGURE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[16]: run: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[17]: ALLOCATE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[18]: CROSSCHECK: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[19]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[20]: sql: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[21]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[22]: BACKUP: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[23]: CROSSCHECK: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[24]: DELETE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[25]: DELETE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh[26]: RELEASE: not found [No such file or directory]
    ./RMAN_DEV_incr1.sh: line 26: syntax error at line 27: `}' unexpected
    ==============
    Here is copy of my shell script:
    #!/bin/ksh
    # Declare your ORACLE environment variables
    export ORACLE_SID=DEV
    export ORACLE_BASE=/d01/oracle/DEV
    export ORACLE_HOME=/d01/oracle/DEV/db/tech_st/11.1.0
    export PATH=$PATH:${ORACLE_HOME}/bin
    # Start the rman commands
    rman target / msglog=/d01/RMAN/logs/rman_INCR_1_${ORACLE_SID}_${DATE}.log
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/d01/RMAN/autobackup_control_file%F';
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    run {
    ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
    CROSSCHECK BACKUP;
    BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE FORMAT '/d01/RMAN/databasefiles_%d_%u_%s_%T';
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT '/d01/RMAN/archivelogs_%d_%u_%s_%T' DELETE INPUT;
    BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/d01/RMAN/controlfile_%d_%u_%s_%T';
    CROSSCHECK BACKUP;
    DELETE NOPROMPT OBSOLETE;
    DELETE NOPROMPT EXPIRED BACKUP;
    RELEASE CHANNEL RMAN_BACK_CH01;
    EXIT;
    EOF
    #

    Hi,
    You missed to redirect the rman command
    rman target / msglog=/d01/RMAN/logs/rman_INCR_1_${ORACLE_SID}_${DATE}.log <<eof
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/d01/RMAN/autobackup_control_file%F';
    CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    run {
    ALLOCATE CHANNEL RMAN_BACK_CH01 TYPE DISK;
    CROSSCHECK BACKUP;
    BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE FORMAT '/d01/RMAN/databasefiles_%d_%u_%s_%T';
    sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
    BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL FORMAT '/d01/RMAN/archivelogs_%d_%u_%s_%T' DELETE INPUT;
    BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE FORMAT '/d01/RMAN/controlfile_%d_%u_%s_%T';
    CROSSCHECK BACKUP;
    DELETE NOPROMPT OBSOLETE;
    DELETE NOPROMPT EXPIRED BACKUP;
    RELEASE CHANNEL RMAN_BACK_CH01;
    EXIT;
    EOF
    #

  • Cold backup using script

    Dear all,
    I need a script to take cold backup of oracle database 10.2.0.3.0 .. such that if todays date is 28-oct-08.. then a folder with the name 28oct08 to be created in the backup location.then using the script user should login to the database shutdown the db and listener and make sure this is completely down and copy the complete oracle files and home location to the above mentioned folder in the server.. any links or points will help a lot ?
    Kai

    Kai, rather than write a script to perform a cold backup for whatever platform you are on I suggest you write a script to generate the cold backup script. The script can connect to the database, read various v$ and dba views such as dba_data_files to get the necessary data file information, and place the file names into OS copy commands. The resulting script should probably include steps to connect to and stop the database and to restart the database instance when it is complete.
    Be sure to include a copy of your control file and the spfile in your backup. You do not need to include the online redo logs in your manual cold backup.
    An alternate might be to run an rman backup while the database is in restricted session depending on how freely your site has given out the DBA role and/or restricted session privilege.
    HTH -- Mark D Powell --

  • Slapconfig backup shell script?

    Trying to create a shell script scheduled with launchctl to backup an open directory master.
    Googling seems to come up with this script:
    #!/usr/bin/expect -f
    spawn /usr/sbin/slapconfig -backupdb "Volumes/MacHD/Backups/odbackup"
    expect “Enter archive password”
    send “password\r”
    expect eof
    It gets caught up on the "Enter archive password" part, and complains that the spawn and send commands are not found.
    Anyone see what I'm doing wrong or can suggest an alternative?

    Ahhhh as always within minutes of posting here, I find an answer.
    Throw above into a file odbackup.txt
    Make a shell script that has:
    cat odbackup.txt
    expect -f odbackup.txt

  • Cold backup automated script

    Hi--
    Can any one provide me one cold backup script,,with that i need to delete 2 days old backup and need to put current backup in that mountpoint.
    Thanks in advance.

    user8683962 wrote:
    We are not using RMAN So what is preventing you from starting? The real value of rman will be when you have to recover, it will already know where all the necessary peices are and what needs to be done. Plus, it will take care of the housekeeping of deleting your old, obsolete backups.
    and Hot backups.....So you don't care if you lose any changes that occur between your cold backups?
    i want to take a cold backup of my database every day and delete need to delete 2 days old backup, so that i can maintain 2 backups(today's and yesterday's) in my hand... Again, rman will do this for you, and more, and much more simply
    for this can any one provide me a script to make it automate by adding to crontab.If someone else hasn't by the time I get back to my hotel room this evening, I'll post an rman solution. It is a waste of time to work on a non-rman solution.

  • Need a shell script to backup archive log daily

    Hi All,
    We need a shell script to backup the archive logs daily after shutting down the concurrent manager and once the backup is completed, needs to start the concurrent manager through the script itself, if you have any ideas or sample scripts, please provide and help us.
    The objective is to backup the daily archive logs with out any loss of data.
    Thanks,

    I do not have a similar script to share, sorry. However, you may review the following links/notes:
    Note: 137181.1 - RMAN Backup Shell Script Example
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=137181.1
    Recovery Manager (RMAN) Manuals
    http://www.oracle.com/pls/db102/homepage

  • Unix shell script to do a cold backup

    i want to do a coldback using a unix shell script.
    the db capacity is around 12 Tb
    wen the backup is done i need to zip it too.at this moment i dont want to copy to the disk.
    kindly help me regarding this
    thanks in advance
    NK

    i used something like this until recently:
    #!/bin/bash
    umask 0077
    export ORACLE_HOME="/u01/app/oracle/product/10.2.0/webdb1"
    export PATH="$ORACLE_HOME/bin:$PATH"
    export NLS_LANG="AMERICAN_AMERICA.WE8ISO8859P1"
    db="dbname"
    pipe="export.pipe"
    file="$db-`date "+%Y-%m-%d"`.dmp"
    if [ ! -p $pipe ]; then
    ## could exist but not be a pipe
    rm -f $pipe
    mknod $pipe p || (echo "could not create pipe $pipe"; exit 1)
    fi
    gzip -c > $file.gz < $pipe &
    exp system/****@$db FULL=Y CONSISTENT=Y FILE=$pipe DIRECT=Y GRANTS=Y
    you could of course also use zip|bzip2|pbzip2 or whatever.
    hth, rgds, armin walland

  • Scripted Cold Backups / Archived Logs / Flashback

    Facts:
    uname -a:
    SunOS {hostname omitted} 5.8 Generic_117350-39 sun4u sparc SUNW,Sun-Fire-V240
    select * from v$version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for Solaris: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Archivelog enabled
    Flashback enabled
    db_flashback_retention_target = 7200 (5 days)
    archive_lag_target = 1800 (30 minutes)
    No, we are not using rman (yet). This system does not have a 24/7 SLA, so we run a cold backup every Saturday: a shell script shuts down the database and copies all the necessary files to a safe location on another host.
    We do have one problem: an accumulation of archived logs. I know that we don't need to keep the logs older than the latest cold backup, but I am unsure of the correct way to clean them up, especially given that we have flashback enabled. Any suggestions?
    Thanks!

    I think maybe I just found the answer to my own question.
    Upon examining the flashback_recovery_area more closely, I see an archivelog directory and a flashback directory, which contains a number of flb files going back to 12/14 (today is 12/20). This makes a certain amount of sense since we have the flashback retention target set to 5 days.
    Would I be correct in stating that the flashback files are self-managing and completely independent of the archived logs?
    Would I also be correct in stating that I can happily delete the archive logs older than my last cold backup?
    The thing which gives me pause is that I swear I remember reading somewhere that flashback uses the archived logs. Did I misunderstand something?

  • Shell Script for automatic backup

    Hello Every one,
    We have windows network and sun solaris sparc box. (both from Sun Box and from Windows machine I can communcate using Telnet.)
    I wish to take data backup of a system having windows operating system, into
    the sun solaris sparc box automatically by week end .
    Can anyone help me with the shell script which does this operation.
    Regards,
    Dwarak

    first of all, is there nfs running? and on windoze box, do u have any nfs client program running?
    you cant transfer files frm the windoze machine via telnet..
    once you can settle the above, what you can do is a simple copy script and put it in your crontab.

  • 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 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

  • Generate RMAN backup Script using unix shell script

    Hello,
    Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
    e.g.
    rman.conf
    CHANNELS=4
    USE_CATALOG=Y
    DEVICE='sbt_tabe'
    etc.,
    many thanks,
    kam

    You can actually encapsulate the RMAN commands inside the shell script.
    However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
    Thus, for example,
    echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
    echo "backup database plus archivelog" >> RMAN_Script.rmn
    echo "backup archivelog all" >> RMAN_Script.rmn
    creates RMAN_Script.rmn with 3 commands.

  • A script for oracle10g cold backup on linux

    Hi,
    I have a urgent need to do a cold backup using o/s command. Can anyone please send me a script for this.
    Thanks in advance
    PK

    I ended up writing the script
    define 3 = &backup_directory
    define 4 = &instance_name
    define 5 = &user_dump_directory
    Set Heading Off
    Set Verify Off
    Set FeedBack Off
    Set LineSize 132
    Set PageSize 1000
    set termout off
    Spool cold_back.sql
    select 'connect /as sysdba' from dual;
    Select 'Startup Force' || CHR(10) ||
    'Shutdown Normal' From Dual;
    select '! mkdir '||'&&3'||'/'||to_char(sysdate,'yyyyddmm') from dual
    /* Data Files */
    Select '!cp ' || File_Name || ' &&3'||'/'||to_char(sysdate,'yyyyddmm') || CHR(10) ||'!gzip ' || '&&3' ||'/'||to_char(sysdate,'yyyyddmm')|| '/' || SubStr(File_Name, InStr(File_Name, '/', -1)+1) From Sys.DBA_Data_Files
    /* Redo Log Files */
    Select '!cp ' || Member || ' &&3'||'/'||to_char(sysdate,'yyyyddmm') || CHR(10) || '!gzip ' || '&&3'||'/'||to_char(sysdate,'yyyyddmm') || '/' || SubStr(Member, InStr(Member, '/', -1)+1) From V$LogFile
    /* Control Files */
    Select '!cp ' || name || ' &&3'||'/'||to_char(sysdate,'yyyyddmm') From V$controlfile
    /* Init and Config Files */
    Select '!cp $ORACLE_HOME/dbs/init&&4' || '.ora &&3'||'/'||to_char(sysdate,'yyyyddmm') From Dual
    alter session set tracefile_identifier=coldbackup
    alter database backup controlfile to trace
    select '!mv '||'&&5/*COLDBACKUP*' ||' &&3'||'/'||to_char(sysdate,'yyyyddmm') FROM dual
    Select 'Startup' From Dual;
    Select 'Exit' from dual;
    set termout on
    PROMPT " Run the output cold_back.sql script [sqlplus -s '/as sysdba' @cold_back.sql ]"
    Spool Off
    -----------------------

  • A decent cold backup script

    Oracle version : 11G release 2
    Platform : AIX
    After going through various OTN posts, i wrote the below Cold backup script (Untested). If there are any unnecessary stuff or enhancements required, please let me know
    $ rman target /
    RMAN>
    run
         allocate channel c1  type disk format '/u05/rmanbkp/%d_COLD_DB_%u';
         sql 'alter system archive log current';
         shutdown immediate;
         startup mount;
         backup database including current controlfile tag='mydbname_full_bkp';
         backup spfile tag = 'mydbname_SPFILE';
         release channel c1;
    }

    Hi T.Boyd
    What do you guys think of the backup script? Any room for improvement? I found in a small percentage of the shutdown immediate commands issued, the instance hangs (specially when the machine is very busy).
    I have modified my rman coldbackup the procedure to:
    shutdown abort;
    host 'sleep 3';
    startup restrict;
    shutdown immediate;
    startup mount;Maybe you can add more channels to improve performance. You can use more resources as there are no users on the database anyway....
    Regards,
    Tycho

Maybe you are looking for