Fuld backup med veritas Netbackup
HejsaJeg sidder og forsøger at lave en fuld backup og tilhørende restore af en Oracle 9.2 med RMAN og Netbackup 5.1. Både backup og restore forløber uden fejl, men hvis jeg sletter en tabel eller et view bliver det ikke restored.
Backup Script:
====================================================
@REM ---------------------------------------------------------------------------
@REM hot_tablespace_backup.cmd
@REM ---------------------------------------------------------------------------
@setlocal ENABLEEXTENSIONS
@echo off
@for /F "tokens=1*" %%p in ('date /T') do @set DATO=%%p
@set RMAN_LOG_FILE="%~dpn0_%DATO%.out"
@if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%
@set ORACLE_HOME=d:\oracle\ora92
@set ORACLE_SID=restorDB
@set TARGET_CONNECT_STR=sys/***@restorDB
@set RMAN=%ORACLE_HOME%\bin\rman.exe
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@echo ==== started on %DATE% ==== >> %RMAN_LOG_FILE%
@echo Script name: %0 >> %RMAN_LOG_FILE%
@set NLS_LANG=american
@set NLS_DATE_FORMAT=YYYY-MM-DD:hh24:mi:ss
@echo # >> %RMAN_LOG_FILE%
@echo RMAN : %RMAN% >> %RMAN_LOG_FILE%
@echo NLS_LANG : %NLS_LANG% >> %RMAN_LOG_FILE%
@echo ORACLE_HOME : %ORACLE_HOME% >> %RMAN_LOG_FILE%
@echo ORACLE_SID : %ORACLE_SID% >> %RMAN_LOG_FILE%
@echo NLS_DATE_FORMAT : %NLS_DATE_FORMAT% >> %RMAN_LOG_FILE%
@echo RMAN_LOG_FILE : %RMAN_LOG_FILE% >> %RMAN_LOG_FILE%
@echo NB_ORA_SERV : %NB_ORA_SERV% >> %RMAN_LOG_FILE%
@echo NB_ORA_FULL : %NB_ORA_FULL% >> %RMAN_LOG_FILE%
@echo NB_ORA_INCR : %NB_ORA_INCR% >> %RMAN_LOG_FILE%
@echo NB_ORA_CINC : %NB_ORA_CINC% >> %RMAN_LOG_FILE%
@echo NB_ORA_CLASS : %NB_ORA_CLASS% >> %RMAN_LOG_FILE%
@if "%NB_ORA_FULL%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=0
@if "%NB_ORA_INCR%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1
@if "%NB_ORA_CINC%" EQU "1" @set BACKUP_TYPE=INCREMENTAL Level=1 CUMULATIVE
@if NOT DEFINED BACKUP_TYPE @set BACKUP_TYPE=INCREMENTAL Level=0
@(
echo RUN {
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo sql 'alter system archive log current';
echo sql 'alter database backup controlfile to trace';
echo SEND 'NB_ORA_CLIENT=oracle-test,NB_ORA_POLICY=oracle_test,NB_ORA_SERV=101dfksans08';
echo BACKUP
echo FORMAT 'bck_%%s_%%p_%%t'
echo DATABASE;
echo RELEASE CHANNEL ch00;
echo # Backup Archived Logs
echo sql 'alter system archive log current';
echo ALLOCATE CHANNEL ch00
echo TYPE 'SBT_TAPE';
echo SEND 'NB_ORA_CLIENT=oracle-test,NB_ORA_POLICY=oracle_test,NB_ORA_SERV=101dfksans08';
echo BACKUP
echo FORMAT 'arc_%%s_%%p_%%t'
echo ARCHIVELOG ALL DELETE INPUT;
echo RELEASE CHANNEL ch00;
echo # Control file backup
echo ALLOCATE CHANNEL ch00
echo TYPE 'SBT_TAPE';
echo SEND 'NB_ORA_CLIENT=oracle-test,NB_ORA_POLICY=oracle_test,NB_ORA_SERV=101dfksans08';
echo BACKUP
echo FORMAT 'bck_%%s_%%p_%%t'
echo CURRENT CONTROLFILE;
echo RELEASE CHANNEL ch00;
echo }
) | %RMAN% target %TARGET_CONNECT_STR% catalog rman/***@rmandb msglog '%RMAN_LOG_FILE%' append
@set ERRLEVEL=%ERRORLEVEL%
@if %ERRLEVEL% NEQ 0 @goto err
@set LOGMSG=ended successfully
@if "%STATUS_FILE%" EQU "" goto end
@echo 0 > "%STATUS_FILE%"
@goto end
:err
@set LOGMSG=ended in error
@if "%STATUS_FILE%" EQU "" @goto end
@echo 1 > "%STATUS_FILE%"
:end
@REM ---------------------------------------------------------------------------
@REM Log the completion of this script.
@REM ---------------------------------------------------------------------------
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@echo # >> %RMAN_LOG_FILE%
@echo %==== %LOGMSG% on %DATE% ==== >> %RMAN_LOG_FILE%
@endlocal
@REM End of Main Program -----------------------------------------------------
================================================
Restore script:
=================================================
@REM $Header: database_restore.cmd,v 1.1 2002/05/28 13:52:47 $
@REM bcpyrght
@REM ***************************************************************************
@REM * $VRTScprght: Copyright 1993 - 2004 VERITAS Software Corporation, All Rights Reserved $ *
@REM ***************************************************************************
@REM ecpyrght
@REM
@REM ---------------------------------------------------------------------------
@REM database_restore.cmd
@REM ---------------------------------------------------------------------------
@REM This script uses Recovery Manager to restore all datafiles, and recover
@REM them completely.
@REM ---------------------------------------------------------------------------
@setlocal ENABLEEXTENSIONS
@REM ---------------------------------------------------------------------------
@REM No need to echo the commands.
@REM ---------------------------------------------------------------------------
@echo off
@REM ---------------------------------------------------------------------------
@REM Put output in the same filename, different extension.
@REM ---------------------------------------------------------------------------
@set RMAN_LOG_FILE="%~dpn0.out"
@REM ---------------------------------------------------------------------------
@REM You may want to delete the output file so that backup information does
@REM not accumulate. If not, delete the following command.
@REM ---------------------------------------------------------------------------
@if exist %RMAN_LOG_FILE% del %RMAN_LOG_FILE%
@REM ---------------------------------------------------------------------------
@REM Replace H:\oracle\ora81, below, with the Oracle home path.
@REM ---------------------------------------------------------------------------
@set ORACLE_HOME=D:\oracle\ora92
@REM ---------------------------------------------------------------------------
@REM Replace ora81, below, with the Oracle SID.
@REM ---------------------------------------------------------------------------
@set ORACLE_SID=restorDB
@REM ---------------------------------------------------------------------------
@REM Replace sys/manager, below, with the target connect string.
@REM ---------------------------------------------------------------------------
@set TARGET_CONNECT_STR=sys/***
@REM ---------------------------------------------------------------------------
@REM Replace %ORACLE_HOME%\bin, below, with the path to the rman executable.
@REM ---------------------------------------------------------------------------
@set RMAN=%ORACLE_HOME%\bin\rman.exe
@REM ---------------------------------------------------------------------------
@REM Log the start of this script.
@REM ---------------------------------------------------------------------------
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@echo ==== started on %DATE% ==== >> %RMAN_LOG_FILE%
@echo Script name: %0 >> %RMAN_LOG_FILE%
@REM ---------------------------------------------------------------------------
@REM Several RMAN commands use time parameters that require NLS_LANG and
@REM NLS_DATE_FORMAT to be set. This example uses the standard date format.
@REM Replace below with the desired language values.
@REM ---------------------------------------------------------------------------
@set NLS_LANG=american
@set NLS_DATE_FORMAT=YYYY-MM-DD:hh24:mi:ss
@REM ---------------------------------------------------------------------------
@REM Print out environment variables set in this script.
@REM ---------------------------------------------------------------------------
@echo # >> %RMAN_LOG_FILE%
@echo RMAN : %RMAN% >> %RMAN_LOG_FILE%
@echo NLS_LANG : %NLS_LANG% >> %RMAN_LOG_FILE%
@echo ORACLE_HOME : %ORACLE_HOME% >> %RMAN_LOG_FILE%
@echo ORACLE_SID : %ORACLE_SID% >> %RMAN_LOG_FILE%
@echo NLS_DATE_FORMAT : %NLS_DATE_FORMAT% >> %RMAN_LOG_FILE%
@echo RMAN_LOG_FILE : %RMAN_LOG_FILE% >> %RMAN_LOG_FILE%
@REM ---------------------------------------------------------------------------
@REM NOTE: We assume that the database is properly opened in a mounted state. If
@REM desired, this would be the place to verify that.
@REM ---------------------------------------------------------------------------
@REM ---------------------------------------------------------------------------
@REM Call Recovery Manager to initiate the restore. This example does not use a
@REM Recovery Catalog. If you choose to use one, remove the option, nocatalog,
@REM from the rman command line below and add a
@REM 'rcvcat <userid>/<passwd>@<tns alias>' statement.
@REM
@REM This script restores all datafiles, and recovers them completely.
@REM All data files are restored to their current locations, from their most
@REM recent backups. It does not restore the control file. If you wish to
@REM omit restoring one or more tablespaces, use the skip tablespace clause
@REM on the restore command.
@REM
@REM Note recovery manager automatically:
@REM o determines whether the controlfile is a backup, and will perform the
@REM correct type of recovery.
@REM o restores any archived redo logs that are currently not on disk,
@REM which are required for recovery.
@REM
@REM If there are incremental backups, it will apply these first, then
@REM apply any redo required to fully recover.
@REM
@REM NOTE WHEN USING TNS ALIAS: When connecting to a database
@REM using a TNS alias, you must use a send command or a parms operand to
@REM specify environment variables. In other words, when accessing a database
@REM through a listener, the environment variables set at the system level are not
@REM visible when RMAN is running. For more information on the environment
@REM variables, please refer to the NetBackup for Oracle Admin. Guide.
@REM
@REM ---------------------------------------------------------------------------
@(
echo RUN {
echo ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
echo ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
echo # Restore all datafiles, and recovers them completely.
echo RESTORE
echo DATABASE;
echo RECOVER
echo DATABASE;
echo RELEASE CHANNEL ch00;
echo RELEASE CHANNEL ch01;
echo }
) | %RMAN% target %TARGET_CONNECT_STR% msglog '%RMAN_LOG_FILE%' append
@set ERRLEVEL=%ERRORLEVEL%
@REM ---------------------------------------------------------------------------
@REM Determine the result of the restore.
@REM ---------------------------------------------------------------------------
@if %ERRLEVEL% NEQ 0 @goto err
@set LOGMSG=ended successfully
@goto end
:err
@set LOGMSG=ended in error
:end
@REM ---------------------------------------------------------------------------
@REM Log the completion of the script.
@REM ---------------------------------------------------------------------------
@for /F "tokens=1*" %%p in ('date /T') do @set DATE=%%p %%q
@for /F %%p in ('time /T') do @set DATE=%DATE% %%p
@echo # >> %RMAN_LOG_FILE%
@echo %==== %LOGMSG% on %DATE% ==== >> %RMAN_LOG_FILE%
@endlocal
@REM End of Main Program -----------------------------------------------------
===========================================