Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: rman unix script?

Re: rman unix script?

From: Joel Garry <joel-garry_at_home.com>
Date: 17 Dec 2003 14:16:59 -0800
Message-ID: <91884734.0312171416.71ae2973@posting.google.com>


susana73_at_hotmail.com (Susan Lam) wrote in message news:<7186ed56.0312161408.3f389c65_at_posting.google.com>...
> Hi,
>
> Where can I find some sample unix script to do rman hotbackup? I
> would like to have a unix script that calls the rman hotbackup
> procedure, which backup files into filesystems and doing
> compression(gzip) during the backup process.
>
> I need the unix script itself, not the rman script that store in rman
> catalog.
>
> Thanks in advance!
> Susan

Here's something I slapped together for a standby db. I don't trust "elsewhere" because it is nfs, and I want to keep the most recent one where I know I can get it, for now. This is for 817 hp-ux. The cron command is like
15 18 * * 1-6 su - oracle -c
"/home/oracle/scripts/nightly_rman_backup.ksh" >> /home/oracle/nightly_rman_backup.out 2>&1

Comments and corrections solicited. Watch for odd wrapping of code in post. Replace stuff in angle brackets with your directories. Your datafiles will vary. Number of channels probably too high. Inappropriate use of RMAN may cause perforation of stomach lining.

#!/bin/ksh
#
# @(#) nightly_rman_backup.ksh - backup and copy backups elsewhere
# 13-Oct-2003 by jgarry
# 
#       Must be run logged in as Oracle.
#
# Save space by compressing directly to elsewhere after comfort level
reached.
# Probably have better I/O that way.

echo "Started: \c"
date

. /usr/local/bin/oradbenv
export TEMP_COPY_FROM=<your backup place> export OBACKUP=<elsewhere>

cd $TEMP_COPY_FROM
echo "Files removed from $OBACKUP"
find $OBACKUP -type f -mtime +1 -exec ll {} \; find $OBACKUP -type f -mtime +1 -exec rm {} \;

echo
echo "Files removed from $TEMP_COPY_FROM" ll
rm *
echo
THE_DATE=`date +%y%m%d`
rman nocatalog cmdfile ~/scripts/backupforstandby.rcv trace backupforstandby${TH
E_DATE}.log
echo "See backupforstandby${THE_DATE}.log for output" echo "RMAN finished: \c"
date
compress *
echo "Files created in $TEMP_COPY_FROM"
ll
cp -p * $OBACKUP
echo
echo "Files in $OBACKUP"
ll $OBACKUP
bdf
echo "Finished: \c"
date
# End of script.

# Script modified from section 5 in Note: 118409 Creating a Standby Database Us
ing RMAN.

#  @(#) backupforstandby.rcv - creates standby database backupset.
# 22-Aug-2003 by jgarry
# 08-Oct-2003 by jgarry, added set limit maxopenfiles to avoid
ORA-4030
# blowing PGA, and changed filesperset from 7 to 4.
#
# run this with:
# rman nocatalog cmdfile backupforstandby.rcv trace
backupforstandby.log
#
# @(#) This expects TEMP_COPY_FROM to be set to a directory.

connect target
run {

allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;

  set maxcorrupt for datafile 1,6,7 to 0;
  set limit channel d1 maxopenfiles = 4;
  set limit channel d2 maxopenfiles = 4;
  set limit channel d3 maxopenfiles = 4;
  set limit channel d4 maxopenfiles = 4;
  backup
  full
  skip inaccessible
  filesperset 4
  tag full_db_standby
  format '$TEMP_COPY_FROM/df_%U'
  database
include current controlfile for standby ; sql "alter system archive log current";
backup archivelog all format '$TEMP_COPY_FROM/al_%U' delete input;
  release channel d1; 
  release channel d2; 
  release channel d3; 
  release channel d4; 

} Received on Wed Dec 17 2003 - 16:16:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US