好学IT学院:IT信息技术分享交流平台
来源:本站整理  作者:学生大读书站  发布时间:2006-12-23  ★★★加入收藏〗〖手机版
摘要://创建一个控制文件命令到跟踪文件 alter database backup controlfile to trace;//增加一个新的日志文件组的语句 connect internal as sysdba alter database ……

REM   For the purposes of this example, this tablespace
REM   will contain two files, data01.dbf and data02.dbf.
REM   The * wildcard will be used in the filename.
REM   alter tablespace DATA begin backup;
!tar -rvf /dev/rmt/0hc /db03/oracle/CC1/data0*.dbf
alter tablespace DATA end backup;
REM
REM   备份 INDEXES tablespace
REM
alter tablespace INDEXES begin backup;
!tar -rvf /dev/rmt/0hc /db04/oracle/CC1/indexes01.dbf
alter tablespace INDEXES end backup;
REM
REM   备份  TEMP tablespace
REM
alter tablespace TEMP begin backup;
!tar -rvf /dev/rmt/0hc /db05/oracle/CC1/temp01.dbf
alter tablespace TEMP end backup;
REM
REM   Follow the same pattern to back up the rest
REM   of the tablespaces.
REM
REM   
REM  Step 2.  备份归档日志文件.
archive log stop
REM
REM   Exit Server Manager, using the indicator set earlier.
exit
EOFarch1
#
#  Record which files are in the destination directory.
#   Do this by setting an environment variable that is
#  equal to the directory listing for the destination 
#  directory.
#  For this example, the log_archive_dest is 
#  /db01/oracle/arch/CC1.
#
FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES
#
#  Now go back into Server Manager and restart the
#  archiving process.  Set an indicator (called EOFarch2
#  in this example).
#
svrmgrl <<EOFarch2
connect internal
archive log start;
exit
EOFarch2
#
#  Now back up the archived redo logs to the tape
#  device via the "tar" command, then delete them
#  from the destination device via the "rm" command.
#  You may choose to compress them instead.
#
tar -rvf /dev/rmt/0hc $FILES
rm -f $FILES

#
#   Step 3.  备份控制文件到磁盘.
#
svrmgrl <<EOFarch3
connect internal
alter database backup controlfile to
   ’db01/oracle/CC1/CC1controlfile.bck’;
exit
EOFarch3
#
#  备份控制文件到磁带.
#
tar -rvf /dev/rmt/0hc /db01/oracle/CC1/CC1controlfile.bck
#
#  End of hot backup script.
//自动生成开始备份的脚本
set pagesize 0 feedback off
select 
  ’alter tablespace ’

Tablespace_Name

’ begin backup;’
  from DBA_TABLESPACES
 where Status <> ’INVALID’
spool alter_begin.sql
/
spool off

//自动生成备份结束的脚本
set pagesize 0 feedback off
select 
  ’alter tablespace ’

Tablespace_Name

’ end backup;’
  from DBA_TABLESPACES
 where Status <> ’INVALID’
spool alter_end.sql
/
spool off

//备份归档日志文件的脚本.
REM  See text for alternatives.
#   Step 1: Stop the archiving process. This will keep
#   additional archived redo log files from being written
#   to the destination directory during this process.
#
svrmgrl <<EOFarch1
connect internal as sysdba
archive log stop;
REM
REM   Exit Server Manager using the indicator set earlier.
exit
EOFarch1
#
#   Step 2: Record which files are in the destination 
#  directory.
#   Do this by setting an environment variable that is
#  equal to the directory listing for the destination 
#  directory.
#  For this example, the log_archive_dest is
#  /db01/oracle/arch/CC1.
#
FILES=`ls /db01/oracle/arch/CC1/arch*.dbf`; export FILES
#
#   Step 3: Go back into Server Manager and restart the
#  archiving process. Set an indicator (called EOFarch2
#  in this example).
#
svrmgrl <<EOFarch2
connect internal as sysdba

  • 好学触屏公众号虎力全开、杨帆起航!
  • 好学考试H5触屏版开放内测