rman全备脚本

# id       
uid=0(root) gid=1(other)

# ./bak.sh
Sun Microsystems Inc.   SunOS 5.9       Generic May 2002
RMAN> RMAN> RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18> 19> 20> 21> 22> 23> 24> 25> 26> 27> 28> RMAN> #
#
#

# more bak.sh
#!/bin/sh

RMAN_LOG_FILE="/export/home/oracle/rmanbak/rman_bak.out"

echo ==== started on `date` ==== >> $RMAN_LOG_FILE

su - oracle -c "rman target / nocatalog msglog $RMAN_LOG_FILE append <<EOF
crosscheck  archivelog  all;
delete  noprompt  expired  archivelog  all;
RUN {
ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;
BACKUP
    INCREMENTAL LEVEL=0
    SKIP INACCESSIBLE
    TAG hot_db_bk_level0
    FILESPERSET 5
    FORMAT '/export/home/oracle/rmanbak/bk_%s_%p_%t'
    DATABASE;
    sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
ALLOCATE CHANNEL ch00 TYPE DISK;
ALLOCATE CHANNEL ch01 TYPE DISK;
BACKUP
   filesperset 20
   FORMAT '/export/home/oracle/rmanbak/al_%s_%p_%t'
   ARCHIVELOG ALL DELETE INPUT;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;

ALLOCATE CHANNEL ch00 TYPE DISK;
BACKUP
    FORMAT '/export/home/oracle/rmanbak/cntrl_%s_%p_%t'
    CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
exit;
EOF"

echo ==== finished on `date` ==== >> $RMAN_LOG_FILE



=========

# pwd
/export/home/oracle/rmanbak

# ls -lt
total 1046672
-rw-r--r--   1 oracle   dba         4425 Jun 13 15:06 rman_bak.out
-rw-r-----   1 oracle   dba      1900544 Jun 13 15:06 cntrl_7_1_657299187
-rw-r-----   1 oracle   dba       402432 Jun 13 15:06 al_5_1_657299186
-rw-r-----   1 oracle   dba         2560 Jun 13 15:06 al_6_1_657299186
-rw-r-----   1 oracle   dba      270508032 Jun 13 15:06 bk_4_1_657299055
-rw-r-----   1 oracle   dba      262766592 Jun 13 15:05 bk_3_1_657299055

你可能感兴趣的:(oracle,C++,c,脚本,sun)