Rman Backup script on Windows

Hello,

Here’s a script I created recently to backup a database under Windows with RMAN.

Hope you enjoy it.

Pierre

The script takes 4 parameters:

  • Target Database Sid
  • Rman Database Sid
  • Rman Database Password
  • Level of Rman backup

—–  Begin Script —–

SET ORACLE_HOME=E:\ORACLEORA10G
SET ORACLE_SID=%1%
SET RMAN_DB=%2%
SET CATALOG_PASS=%3%
SET LEVELBCK=%4%
SET CATALOG_PASS=rman/%CATALOG_PASS%@%RMAN_DB%
SET RMAN_DEST=K:\SAUVEGARDESRMAN%ORACLE_SID%
SET LOG_DEST=K:\SAUVEGARDESLOGS
SET NLS_LANG=AMERICAN_AMERICA.UTF8
SET TMPDIR=E:\ORACLETEMPSCRIPTS

@echo on

cd %TMPDIR%

REM This bit generates the RMAN script to backup database,
REM archivelogs and control file and then crosscheck output.
echo run { > rman_%ORACLE_SID%.rcv
echo allocate channel d1 type disk; >> rman_%ORACLE_SID%.rcv
echo allocate channel d2 type disk; >> rman_%ORACLE_SID%.rcv
echo allocate channel d3 type disk; >> rman_%ORACLE_SID%.rcv
echo backup incremental level %LEVELBCK% format
‘%RMAN_DEST%DBF_%ORACLE_SID%_t%%t_s%%s_p%%p.db’
database;>>rman_%ORACLE_SID%.rcv
echo sql ‘alter system archive log current’; >>rman_%ORACLE_SID%.rcv
echo backup archivelog all format
‘%RMAN_DEST%ARC_%ORACLE_SID%_t%%t_s%%s_p%%p.arc’;>>rman_%ORACLE_SID%.rcv
echo backup current controlfile format
‘%RMAN_DEST%CTL_%ORACLE_SID%_t%%t_s%%s_p%%p.ctl’;>>rman_%ORACLE_SID%.rcv
echo release channel d1; >> rman_%ORACLE_SID%.rcv
echo release channel d2; >> rman_%ORACLE_SID%.rcv
echo release channel d3; >> rman_%ORACLE_SID%.rcv
echo } >> rman_%ORACLE_SID%.rcv
echo allocate channel for maintenance type disk; >> rman_%ORACLE_SID%.rcv
echo sql ‘alter system archive log current’; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup of archivelog all; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup of controlfile; >> rman_%ORACLE_SID%.rcv
echo release channel; >> rman_%ORACLE_SID%.rcv
echo exit >> rman_%ORACLE_SID%.rcv

REM This starts RMAN, executes the script created earlier, then exits and
tidies up.
cd %RMAN_DEST%
if %LEVELBCK%==1 goto INCR
if %LEVELBCK%==0 goto FULL

:FULL
del %RMAN_DEST%*.* /q
rman target / catalog=%CATALOG_PASS% cmdfile=%TMPDIR%rman_%ORACLE_SID%.rcv
msglog=%LOG_DEST%rman_%ORACLE_SID%.log
del %TMPDIR%rman_%ORACLE_SID%.rcv
goto END
:INCR
rman target / catalog=%CATALOG_PASS% cmdfile=%TMPDIR%rman_%ORACLE_SID%.rcv
msglog=%LOG_DEST%rman_%ORACLE_SID%.log
del %TMPDIR%rman_%ORACLE_SID%.rcv
:END

—- end script —-

Advertisements

Network import with DataPump

With DataPump, there is no need to create an export file anymore, if the sole purpose is to import data.

 

Before proceeding with the import, the following needs to be configured:

 

  • Create a streams pool (50Mb)
  • Create a directory (Since there is no export file involved, it serves as the location of the datapump logfile, there is no export file involved)
  • Grant read-write privileges on the datapump directory to the datapump user
  • Create a public database link to the remote database

 

Import with DataPump

Generic Example: (in this case I connected to the remote schema directly)

 

  1. alter system set streams_pool_size=50Mb scope=both;
  2. create directory DATAPUMP_DIR as ‘/export/datapump’;
  3. grant read, write on directory DATAPUMP_DIR to DPEDEV;
  4. create public database link RDPEPRD connect to DPEPRD identified by DPEPRD using ‘rdpeprd’;
  5. impdp dpedev/dpedev directory=datapump_dir network_link=RDPEPRD REMAP_SCHEMA=DPEPRD:DPEDEV

 Make sure the remote user has the EXP_FULL_DATABASE role

Pierre