dmk_rman.{ksh|ps1}

This chapter presents the RMAN wrapper script dmk_rman{ksh|ps1}.

All scripts have a detailed synopsis. Please check the option “-h” or “—help”.

The execution of dmk_rman.{ksh|ps1} requires a configuration file, which contains the following parameters.

The script requires command lines argument in addition to the configuration file. Some of the configuration file parameters are also available in command-line. The parameters given in command line are from higher priority compared to their configuration values. Which allows different behave using the same configuration file.

Example:

  • The default configuration parameter BackupType is “bck_inc0.rcv”, so the below command start an full incremental database backup level 0.

dmk_rman.ksh –s ${ORACLE_SID}
  • To launch an Archivelog Backup using the same configuration as above launch the script as follows

dmk_rman.ksh –s ${ORACLE_SID} –t bck_arc.rcv

Once all parameters have been computed dmk_rman starts to look at the specified RMAN rcv script and replace the placeholders with the value of the below parameters. In addition, some parameters are automatically generated by dmk_rman like the placeholder <START_DATE>.

  • Microsoft Windows Task Scheduler doesn’t launch directly the PowerShell layer.

However, starting PowerShell from the DOS layer shall be achieved using the following syntax:

powershell.exe –noprofile ^
–command "dmk_rman.ps1 –s ${ORACLE_SID} –t bck_arc.rcv"

DOS batch scripts can then be used to execute backups through the Windows Task Scheduler. This DOS batch script will execute PowerShell with the appropriate dmk_rman.ps1 commands as explained previously. Note that for the same ORACLE_SID a different batch file needs to be used for each PowerShell backup command.

The PowerShell profile is similar to the Unix/Linux user profile (~/.profile, ~/.bash_profile). The “-noprofile” option bypass the sourcing of the user profile.

Example of rman_TEST_arc.cmd DOS batch script to backup archive logs for TEST database using bck_arc.rcv rman script file :

@echo off
SET DMK_HOME=C:\\oracle\\local\\dmk
powershell.exe -noprofile ^
command "C:\\oracle\\local\\dmk_dbbackup\\bin\\dmk_rman.ps1 -s TEST -t bck_arc.rcv"

Example of Windows Task Scheduler configuration :

Getting started with “dmk_rman.{ksh|ps1}” requires to copy the template RCV scripts provided:

cp –p ${DMK_DBBACKUP}/templates/rcv/oracle[10|11|12]/*.rcv \\
${DMK_DBBACKUP}/rcv/oracle[10|11|12]/

Please refer to the Appendix chapter, paragraph 9.4 Templates RCV for details.

⚠ī¸Oracle 18c and 19c databases will be considered as been part of the oracle 12c family and therefore oracle12 rcv files will be used. Make sure to copy the appropriate needed rcv file into ${DMK_DBBACKUP}/rcv/oracle12.

ℹī¸ The dmk_dbbackup result codes are :

  • OK : Prescript, rman backup, postscript are all OK

  • WARNING : rman backup is ok, but there is an error on either the prescript or the postscript

  • ERROR : There is an error with the rman backup (connection failure, backup, any RMAN-XXXXX errors.

Parameters

A hyphen character prefixes the command line parameters as they are be used within a shell.

–h or –help

Display the Synopsis.

–s or -–sid

The target database on which, the Oracle RMAN operation should be launched. This parameter is always required.

dmk_rman.ksh –s ${ORACLE_SID}

–u or –-usecatalog

With this option, there is now 2 ways left for doing backup with the catalog :

  • None

  • Always (default)

  • resync_only (has been deprecated)

Using this parameter is only possible with the CLI.

⚠ī¸In case there is no catalog connection added into the rman configuration file, the backup will be done without catalog and this --usecatalog option will be ignored.

none option

When using “none” option, the catalog will not be used at all even if configured in the rman configuration file (default rman.cfg).

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -u none
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_113903.lo
g

always option

When using “always” option, the catalog will be used during the whole backup process. A connection is made immediately at the beginning before doing the backup commands. This is the default option when usecatalog is not mentioned in the CLI and a catalog connection is configured in the configuration file (rman.cfg).

usecatalog always is the default option:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv
2021-07-07_11-32-36::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 0 (0 means do not continue
on errors, 1 means continue on errors).
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_113235.lo
g

usecatalog always can still be used in the CLI:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -u always
2021-07-07_11-35-09::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 0 (0 means do not continue
on errors, 1 means continue on errors).
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_113508.lo
g

In case the always option is enforced in the CLI albeit there is no catalog entry in the configuration file, the program will exit with an error 5026 - CLI use catalog value is always and there is no catalog configured. Exiting.

oracle@vmtestoradg1:/ u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
catalog rman.cfg
#RMAN Catalog connection string
catalog="nocatalog"
oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -u always
2021-07-07_11-30-12::dmk_rman_sid.pl::MainProgram ::ERROR ==> 5026 -
CLI use catalog value is always and there is no catalog configured. Exiting.

-usecatalog_continue_on_errors

A new parameter, --usecatalog_continue_on_errors, has been introduced and is only taken in account with the always option case. This parameter is only usable with command line (CLI). When added to the CLI, the backup will still move forward even if connection with the catalog is failing. The backup will move forward with the control_file as backup metadata, and will be usable.

ℹī¸In case a backup script should not be completed without an available catalog connection as backup deletion for example, do not use --usecatalog_continue_on_errors option. The backup script will stop immediately on catalog connection error, will fail and no operation will be further performed. The backup result code is 1 (ERROR).

In case a backup script still needs to move forward even if the catalog is not available, as archive log backups for example, in order to avoid FRA management problem, add the --usecatalog_continue_on_errors option in the CLI. The backup script will generate an error on the catalog connection but will still move forward and be executed. The global backup dmk_dbbackup script result code will still be 1 (ERROR) due to the catalog connection issue but will be usable.

In case the --usecatalog_continue_on_errors is used and there is a catalog connection issue, the global dmk_dbbackup script will end with an error code even if the backup is successfully completed. Solving the catalog connection issue is still mandatory and still need high attention.

⚠ī¸ Reminder about the dmk_dbbackup return codes :

  • OK : Prescript, rman backup, postscript are all OK

  • WARNING : rman backup is ok, but there is an error on either the prescript or the postscript

  • ERROR : There is an error with the rman backup (connection failure, backup, any RMAN-XXXXX errors.

use catalog always option without continue on errors:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv
2021-07-07_13-10-22::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 0 (0 means do not continue
on errors, 1 means continue on errors).
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0

Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_131021.lo
g

use catalog always option with continue on errors:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv --usecatalog_continue_on_errors
2021-07-07_13-25-48::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 1 (0 means do not continue
on errors, 1 means continue on errors).
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_132547.lo
g

In case of RMAN catalog failure and --usecatalog_continue_on_errors is not activated, the backup will fail and stop immediately:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv
2021-07-07_14-18-53::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 0 (0 means do not continue
on errors, 1 means continue on errors).
[ERROR]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::-1
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_141852.lo
g
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04004: error from recovery catalog database: ORA-12514: TNS:listener
does not currently know of service requested in connect descriptor
oracle@vmtestoradg1:/home/oracle/ [DB19C] cat
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_141852.lo
g
#***************************************************************************
***********************#
# File: DB19C_bck_inc0_no_arc_del_20210707_141852.log
#
#---------------------------------------------------------------------------
-----------------------#
# timestamp: 2021-07-07_14:18:53
#
#***************************************************************************
***********************#
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Jul 7 14:18:53 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights
reserved.
connected to target database: DB19C (DBID=2146829258)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04004: error from recovery catalog database: ORA-12514: TNS:listener
does not currently know of service requested in connect descriptor
RMAN return Code: 1
#***************************************************************************
***********************#
# END OF: DB19C_bck_inc0_no_arc_del_20210707_141852.log
#
#---------------------------------------------------------------------------
-----------------------#
# timestamp: 2021-07-07_14:18:55
#
#***************************************************************************
***********************#

In case of failure with the RMAN catalog and --usecatalog_continue_on_errors is activated, the backup will move forward as seen in the following log file. The backup will still end with a return code of 1 on a RMAN error to alert on the catalog problem which needs to be solved as soon as possible:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv --usecatalog_continue_on_errors
2021-07-07_14-19-42::dmk_rman_sid.pl::MainProgram ::INFO ==> Use
catalog is always and continue on error is set to 1 (0 means do not continue
on errors, 1 means continue on errors).
[ERROR]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::-1
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_141941.lo
g
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-04004: error from recovery catalog database: ORA-12514: TNS:listener
does not currently know of service requested in connect descriptor
oracle@vmtestoradg1:/home/oracle/ [DB19C] more
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_141941.lo
g
...
...
...
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Jul 7 14:19:42 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights
reserved.

connected to target database: DB19C (DBID=2146829258)
RMAN>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-04004: error from recovery catalog database: ORA-12514: TNS:listener
does not currently know of service requested in connect descriptor
...
...
...
Starting backup at 07-JUL-2021 14:19:45
channel disk1: starting incremental level 0 datafile backup set
channel disk1: specifying datafile(s) in backup set
input datafile file number=00001
name=/u02/oradata/DB19C/datafile/o1_mf_system_gqnkwl5l_.dbf
input datafile file number=00003
name=/u02/oradata/DB19C/datafile/o1_mf_sysaux_gqnkxobl_.dbf
input datafile file number=00004
name=/u02/oradata/DB19C/datafile/o1_mf_undotbs1_gqnky4g2_.dbf
input datafile file number=00007
name=/u02/oradata/DB19C/datafile/o1_mf_users_gqnky5k4_.dbf
channel disk1: starting piece 1 at 07-JUL-2021 14:19:45
channel disk1: finished piece 1 at 07-JUL-2021 14:20:10
piece
handle=/u01/app/oracle/admin/DB19C/backup/20210707_141941_inc0_DB19C_2146829
258_s407_p1.bck tag=INC0_20210707_141941 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:25
Finished backup at 07-JUL-2021 14:20:10
Starting backup at 07-JUL-2021 14:20:11
current log archived
skipping archived logs of thread 1 from sequence 41 to 45; already backed up
skipping archived logs of thread 1 from sequence 43 to 44; already backed up
skipping archived logs of thread 1 from sequence 1 to 40; already backed up
skipping archived logs of thread 1 from sequence 38 to 39; already backed up
skipping archived logs of thread 1 from sequence 1 to 100; already backed up
channel disk1: starting archived log backup set
channel disk1: specifying archived log(s) in backup set
input archived log thread=1 sequence=101 RECID=362 STAMP=1077286811
channel disk1: starting piece 1 at 07-JUL-2021 14:20:11
channel disk1: finished piece 1 at 07-JUL-2021 14:20:12
piece
handle=/u01/app/oracle/admin/DB19C/backup/20210707_141941_arc_DB19C_21468292
58_s408_p1.bck tag=ARCH_20210707_141941 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-JUL-2021 14:20:12
Starting backup at 07-JUL-2021 14:20:12
channel disk1: starting full datafile backup set
channel disk1: specifying datafile(s) in backup set
including current control file in backup set
channel disk1: starting piece 1 at 07-JUL-2021 14:20:13
channel disk1: finished piece 1 at 07-JUL-2021 14:20:14
piece
handle=/u01/app/oracle/admin/DB19C/backup/20210707_141941_ctl_DB19C_21468292
58_s409_p1.ctl tag=CTRL_20210707_141941 comment=NONE
channel disk1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-JUL-2021 14:20:14
Starting Control File and SPFILE Autobackup at 07-JUL-2021 14:20:14
piece handle=/u01/app/oracle/admin/DB19C/backup/20210707_141941_c2146829258-20210707-0a comment=NONE
Finished Control File and SPFILE Autobackup at 07-JUL-2021 14:20:15
sql statement: create
pfile=''/u01/app/oracle/admin/DB19C/backup/init_DB19C.ora'' from spfile
released channel: disk1
RMAN> # DMK_DBBACKUP - automatic RMAN catalog always.
2> **end-of-file**
RMAN>
Recovery Manager complete.
RMAN return Code: 1
#***************************************************************************
***********************#
# END OF: DB19C_bck_inc0_no_arc_del_20210707_141941.log
#
#---------------------------------------------------------------------------
-----------------------#
# timestamp: 2021-07-07_14:20:16
#
#***************************************************************************
***********************#

resync_only option

When using “resync_only”, the backup will be done without a catalog connection. The metadata will be stored in the control files and a resync between the control files and the catalog will be performed at the end, after the backup is completed. So 2 return codes will be seen in the log file. The first one for the backup and the second one for the resync. If the catalog is not available, the return code for the resync will show failure, but the backup could still be successful and usable.

Please note that this option has been deprecated and kept only for backwards compatibility. In case resync_only is used, a warning will now be displayed in the console. A warning note will also be added to the email body and will be sent according to the email configuration policy.

oracle@vmtestoradg1:/home/oracle/ [DB19C] dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -u resync_only
2021-07-07_11-43-06::dmk_rman_sid.pl::MainProgram ::WARNING ==>
GlobalParams(usecatalog) option [resync_only] is DEPRECATED. Please consider
moving to ALWAYS or NONE.
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210707_114305.lo
g

–c or –-configfile

The dbi services best practice consist of saving the configuration file under the database admin directory which makes the command-line parameter “ConfigFile” useless

cp ${DMK_DBBACKUP}/templates/rman.cfg \\
 ${DMK_ORA_ADMIN_SID}/etc/rman.cfg

Otherwise the command-line parameter becomes mandatory

dmk_rman.ksh –s ${ORACLE_SID} –c <path to the configuration file>

Catalog

#*************************************************************
#RMAN Catalog
catalog="nocatalog"
#catalog=user/pwd@<CATALOG_SID>

Target

#*************************************************************
# RMAN Connect string for target database
# especially useful for remote backups
# Default is : ""
#target="user/pwd@<TNS_ALIAS>"
#target="user/pwd@<TNS_ALIAS> AS SYSBACKUP"
target=""

–d or --channeltype

#*************************************************************
# Commandline : --channeltype or -d
# Type of channel to allocate
# Valid types are "disk" or "sbt_tape"
# Default is : "disk"
ChannelType="disk"

–n or --channelnbr

#*************************************************************
# Commandline : --channelnbr or -n
# Number of RMAN channel to allocate
# Default is : "1"
ChannelNbr="1"

–p or –-channelparms

#*************************************************************
# Commandline : --channelparams or -p
# RMAN Channel allocation parameters
# Multiple lines allowed! REQUIRES QUOTES " to delimit
# the whole string as shown below :
# ChannelParms="PARMS='SBT_LIBRARY=oracle.disksbt,
# ENV=(BACKUP_DIR=/dev/null)'"
# Default is : "<null>"
ChannelParms=""

–t or –-backuptype

#*************************************************************
# Commandline : --backuptype or –t
#	RMAN	rcv	script	which	will	be	executed
# By ommitting an absolute path dmk_rman searchs a template
# under the directory $DMK_DBBACKUP\\rcv\\Oracle[10|11]
# Default is : "bck_inc0.rcv"
Backup_Type="bck_inc0.rcv"

RetPolicy

#*************************************************************
# RetPolicy
# RMAN Backup retention policiy, recovery window
# Default is : "" - 4 Days
RetPolicy=""

Per default, an RMAN recovery window of 4 Days is set by DMK_DBBACKUP. This parameter can be set to a value less than the default if desired.

ArchDelPolicy

#*************************************************************
# ArchDelPolicy
# RMAN Archive deletion policiy
# Default is "NONE"
# "APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK"
# "BACKED UP 1 TIMES TO DISK"
# "APPLIED ON ALL STANDBY"
ArchDelPolicy="NONE"

Per default, the RMAN ARCHIVELOG DELETION POLICY is set to “NONE”. This parameter can be set to a different value if required.

ArchDelPolicySTD

#*************************************************************
# ArchDelPolicySTD
# RMAN Archive deletion policy
# Default is "APPLIED ON ALL STANDBY"
# "NONE"
# "BACKED UP 1 TIMES TO DISK"
# "APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK"
ArchDelPolicySTD="APPLIED ON ALL STANDBY"

Per default, the RMAN ARCHIVELOG DELETION POLICY for the Standby is set to “APPLIED ON ALL STANDBY”. This parameter can be set to a different value if required.

Bck_Path

#*************************************************************
# Bck_Path
# Backup destination
# Default is : "" - $DMK_ORA_ADMIN_SID/backup
# If you perform RMAN backups to the FRA, use the appropriate RCV template
# as the FRA is database defined destination
BckPath=""

If the backup directory doesn’t exist, the RMAN operation will abort!

Fully qualified path without variable is expected if not taking default location.

BlckChangePath

#*************************************************************
# BlckChange
# Block Change Tracking File destination
# Will be manually manage independently if database is OMF or not
# Default is : "" - BckPath
# Recommendation is to have the block change tracking file located in the
oracle data directory
BlckChangePath=""

Path used to store the block change tracking file. This parameter is used with the following rcv files:

bck_inc0_no_arc_del_blck_chg_trk.rcv

bck_inc1_blck_chg_trk.rcv

NFSTimeout

#*************************************************************
# NFSTimeOut
# NFS Timeout, to handle stalled NFS for the BckPath
# Default is : "10" seconds
NFSTimeout="10"

With this parameter we can handle the NFS stalled problem, the process do exit if the timeout is reached!

Log_Path

#*************************************************************
# Log_Path
# Destination of the log files
# Default is : "" - $DMK_ORA_ADMIN_SID/log
LogPath=""

If the log file directory doesn’t exist it will be automatically created, a warning message announce this operation.

Fully qualified path without variable is expected if not taking default location.

Nbr_Files_per_Set

#*************************************************************
# Number of Files per backup piece
# Default is : "10"
Nbr_Files_per_set="10"

Nbr_Files_per_Arc_set

#*************************************************************
# Number of archivelop files per archive backup piece
# Default is : "10"
Nbr_Files_per_arc_set="10"

Section_Size

#*************************************************************
# Oracle 12c - multisection backup support
# Default is : "8G"
Section_Size="8G"

–z or --compress

#*************************************************************
# Commandline : --compress or -z
# RMAN Compressed Backup
# Default is : "0" - non compressed
# "1" - compressed
Compress="0"

PreScript

#*************************************************************
# Launch a pre Export script
# the logfile is written under LogPath
# Default is : ""
PreScript=""

This gives the possibility for the user to execute a batch script (windows) or a shell script (linux) before executing the backup.

⚠ī¸If no full qualified path is given, but only the script name preceded by ./ for linux, dmk_rman is expected to be run in the current directory where the script is located. Otherwise, the user needs to give the full qualified path without using variables.

ℹī¸DMK_DBBACKUP considers only the return code of the script to check whether the execution was successful or not.

PostScript

#*************************************************************
# Launch a post Backup script
# the logfile will be written under log_path parameter
# Default is : ""
PostScript=""

This gives the possibility for the user to execute a batch script (windows) or a shell script (linux) after executing the backup.

⚠ī¸If no full qualified path is given, but only the script name preceded by ./ for linux, dmk_rman is expected to be run in the current directory where the script is located. Otherwise, the user needs to give the full qualified path without using variables.

ℹī¸ DMK_DBBACKUP considers only the return code of the script to check whether the execution was successful or not.

Customer

#*************************************************************
# Name/ShortName of the customer
# Default is : "dbi-services"
Customer="dbi-services-Ltd"

-nosuccessmail

#*************************************************************
# Commandline : --nosuccessmail
# "0" -means the sucessmail will be sent as well
# "1" -means that email will be only sent in case of problem or error
# Default is : "0"
NoSuccessMail="0"

MailRecipients

#*************************************************************
# MailRecipients
# comma separated list of mail recipients
# Default is : "" - empty
MailRecipients=""

SmtpServer

#*************************************************************
# SmtpServer
# Infrastructure SMTP server
# Default is : "" - localhost
SmtpServer=""

MailFrom

A hyphen character prefixes the command line parameters as they are being used within a shell.

Each parameter defined within the configuration file is automatically parsed at runtime and environment variables defined as values implicitly expanded. Syntax:

#*************************************************************
# MailFrom
# Hardcode address From sender
# Default is : "" - ${USERNAME}.${HOSTNAME}@${DOMAIN}
MailFrom="$ENV{USERNAME}.$ENV{HOST}@domain.com"

Real dbbackup implementation case example

This chapter is only intended to give an overview of an example of a dbbackup implementation during a consulting project. There is no intention to say it is the only way to perform an installation and all projects are different.

This installation applies to a configuration where:

  • Data Guard is in used

  • The system is composed with a primary (vmtestoradg1) and a least one standby (vmtestoradg2) database servers

  • The archive logs are stored in the FRA. Archive logs will not be deleted during the backup script, and we will rely on oracle to remove the archive logs made reclaimable if place is needed.

  • The backups are executed through the linux crontab.

  • We would like to run

    • at 22:00 every day an inc0 backup

    • every 4 hours an archived log backup.

    • every day at 06:00 a backup deletion

    • every 4 hours an archive log deletion policy changes on the standby to ensure the policy is set accordingly in case there were a recent switchover. No other backup script will be run on the standby database.

As we are using a configuration with 2 servers one for the primary and one for the standby we expect both servers to be configured the same way. Each server can one time hold either the primary database or the standby database.

Our instance is called DB19C. Our primary db_unique_name is DB19C_SITE1 when the standby db_unique_name is DB19C_SITE2. Our database version is 19c, therefore we will use the rcv template from the oracle12 folder. Reminder, all versions up to 12c use the rcv files from the oracle12 folder.

Archive log deletion policy

The archive log deletion policy will define when oracle will be able to setup an archive log as reclaimable in order to delete it if space is needed (more than 80% of the FRA is in used).

In our case, the archive log deletion policy will have to be configured as following:

  • “APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK” when the database is primary

  • “APPLIED ON ALL STANDBY” when the database is standby

Configure rman.cfg file

We will consider that the following directories were already created for the specific instance on both primary and standby servers:

oracle@vmtestoradg1:/home/oracle/ [DB19C] cda
oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/ [DB19C] ls
adump backup create etc log pfile xdb_wallet

We will then first copy the rman.cfg template which we will adapt as needed:

oracle@vmtestoradg1:/home/oracle/ [DB19C] dbbackup
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/ [DB19C] cp -p
templates/rman.cfg $DMK_ORA_ADMIN_SID/etc/
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/ [DB19C] cda
oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/ [DB19C] cd etc
oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] ls -l
total 8
-rw-r--r--. 1 oracle oinstall 5277 Jul 7 15:30 rman.cfg
oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] vi rman.cfg

Backup path location

We will consider that the backups will be recorded in the default backup location (u01/app/oracle/admin/DB19C/backup). A symbolic link could be created in order to have the backup recorded in another file system, or the additional file system could be mounted as default backup location.

In that case we will not configure the BckPath parameter and leave it empty. In case we use a NFS shared drive, this parameter will need to be updated with the NFS mount point.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^bckpath rman.cfg
BckPath=""

catalog

Recommendation is to use a catalog and have a catalog already deployed.

The catalog parameter will need to be updated as following in case of no catalog:

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^catalog rman.cfg
catalog="nocatalog"

The catalog parameter will need to be updated as following in case a catalog is used:

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^catalog rman.cfg
catalog=rmancat/rmancat@RMANCAT

Retention policy

Backup retention policy needs to be configured accordingly to the need. In our case we will keep the default 4 days value.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^retpolicy rman.cfg
RetPolicy=""

Channels

Knowing we are using EE Edition, we will configure disk channel type with 4 parallel channels (this is just an example, and would need to be adapted to the customer environment and requirements).

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^channel rman.cfg
ChannelType="disk"
ChannelNbr="4"
ChannelParms=""

Default backup type

By default, if not mentioned in the dmk_rman.ksh command, we would like to run an inc0 backup. Therefore we will configure the appropriate script as been the default one.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^backup_type rman.cfg
Backup_Type="bck_arc_no_arc_del.rcv"

Archive log deletion policy

We will configure the archive log deletion policy as mentioned in the 6.2.1 part.

ArchDelPolicy parameter is used for the primary database when ArchDelPolicySTD is used for the standby database.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
^archdelpolicy rman.cfg
ArchDelPolicy="APPLIED ON ALL STANDBY BACKED UP 1 TIMES TO DISK"
ArchDelPolicySTD="APPLIED ON ALL STANDBY"

Additional parameters

The following additional parameters need to be configured according to the customer environment.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] grep -i
'^customer\\|^nosuccessmail\\|^mailrecipients\\|^smtpserver\\|^mailfrom'
rman.cfg
Customer="dbi-services-Ltd"
NoSuccessMail="0"
MailRecipients=""
SmtpServer=""

The rman.cfg will have to be copied with the scp command to the standby server as well.

oracle@vmtestoradg1:/u01/app/oracle/admin/DB19C/etc/ [DB19C] scp rman.cfg
oracle@vmtestoradg2:$PWD/
rman.cfg 100% 5332 3.7MB/s 00:00

rcv script files

We now need to copy the rcv script files we will use from the template directory. We are running database version 19c, so we will use the templates from the oracle12 directory and copy them into the appropriate running rcv directory. This rcv scripts have the needed variable in relation to the rman.cfg file.

For our implementation we will use following rcv templates:

  • bck_inc0_no_arc_del.rcv

  • bck_arc_no_arc_del.rcv

  • change_arc_del_policy.rcv

  • mnt_obs.rcv

oracle@vmtestoradg1:/home/oracle/ [DB19C] dbbackup
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/ [DB19C] cd
rcv/oracle12
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]
ls
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]
cp -p
../../templates/rcv/oracle12/{bck_inc0_no_arc_del.rcv,bck_arc_no_arc_del.rcv
,change_arc_del_policy.rcv,mnt_obs.rcv} .
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]
ls
bck_arc_no_arc_del.rcv bck_inc0_no_arc_del.rcv change_arc_del_policy.rcv
mnt_obs.rcv
oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]

We need to copy the same file into the standby server.

oracle@vmtestoradg1:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]
scp *.rcv oracle@vmtestoradg2:$PWD/
bck_arc_no_arc_del.rcv 100% 903 1.6MB/s 00:00
bck_inc0_no_arc_del.rcv 100% 1168 2.1MB/s 00:00
change_arc_del_policy.rcv 100% 751 1.3MB/s 00:00
mnt_obs.rcv 100% 294 668.5KB/s 00:00

Setup crontab

oracle@vmtestoradg1:/home/oracle/ [DB19C] crontab -l
no crontab for oracle
oracle@vmtestoradg1:/home/oracle/ [DB19C] crontab -e
no crontab for oracle - using an empty one
crontab: installing new crontab
oracle@vmtestoradg1:/home/oracle/ [DB19C] crontab -l
#==========================================================
# Crontab for Oracle user
# Used to run Oracle related jobs
#----------------------------------------------------------
# Version Date Author Comment
# 1.0 14.07.2021 Marc Wagner Initial release
#
#
#minutes (0-59),
#| hours (0-23),
#| | day of month (1-31),
#| | | month of year (1-12),
#| | | | day of week (0-6 with 0=Sunday).
#| | | | | commands
#==========================================================
#-------------------------------------------------------
# DB19C database
#-------------------------------------------------------
#Full incremental level 0 backup for DB19C database
0 22 * * * /u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
>/tmp/run_bck_inc0_DB19C.log 2>&1
#Archivelogs backup every 4 hours for DB19C database
0 */4 * * * /u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_arc_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
>/tmp/run_bck_arc_DB19C.log 2>&1
#Backups deletion for DB19C database
0 6 * * * /u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t mnt_obs.rcv
-c /u01/app/oracle/admin/DB19C/etc/rman.cfg" >/tmp/run_del_obs_DB19C.log
2>&1
#Change ARCHIVE LOG DELETION POLICY if database becomes Standby every 4
hours
0 */4 * * * /u01/app/oracle/local/dmk_ha/bin/check_standby.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
change_arc_del_policy.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
>/tmp/run_change_policy_DB19C.log 2>&1

We will use both check_primary.ksh and check_standby.ksh scripts from the dmk_ha plugin in order to have both servers configured the same way and to execute the appropriate scripts in relation to the current databases role.

Test the backups

On the primary server

Inc0 backup:

oracle@vmtestoradg1:/home/oracle/ [DB19C]
/u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
2021-07-14_15:11:30::check_primary.ksh::SetOraEnv ::INFO ==>
Environment: DB19C (/u01/app/oracle/product/19.3.0/dbhome_1)
2021-07-14_15:11:30::check_primary.ksh::MainProgram ::INFO ==> Getting
V$DATABASE.DB_ROLE for DB19C
2021-07-14_15:11:32::check_primary.ksh::MainProgram ::INFO ==> DB19C
Database Role is: PRIMARY
2021-07-14_15:11:32::check_primary.ksh::MainProgram ::INFO ==> Program
going ahead and starting requested command
2021-07-14_15:11:32::check_primary.ksh::MainProgram ::INFO ==> Script :
/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_inc0_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_inc0_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_inc0_no_arc_del_20210714_151132.lo
g
2021-07-14_15:11:50::check_primary.ksh::CleanExit ::INFO ==> Program
exited with ExitCode : 0

Archive log backup:

oracle@vmtestoradg1:/home/oracle/ [DB19C]
/u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_arc_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
2021-07-14_15:12:51::check_primary.ksh::SetOraEnv ::INFO ==>
Environment: DB19C (/u01/app/oracle/product/19.3.0/dbhome_1)
2021-07-14_15:12:51::check_primary.ksh::MainProgram ::INFO ==> Getting
V$DATABASE.DB_ROLE for DB19C
2021-07-14_15:12:52::check_primary.ksh::MainProgram ::INFO ==> DB19C
Database Role is: PRIMARY
2021-07-14_15:12:52::check_primary.ksh::MainProgram ::INFO ==> Program
going ahead and starting requested command
2021-07-14_15:12:52::check_primary.ksh::MainProgram ::INFO ==> Script :
/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
bck_arc_no_arc_del.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::bck_arc_no_arc_del.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_bck_arc_no_arc_del_20210714_151252.log
2021-07-14_15:13:03::check_primary.ksh::CleanExit ::INFO ==> Program
exited with ExitCode : 0

Backup deletion:

oracle@vmtestoradg1:/home/oracle/ [DB19C]
/u01/app/oracle/local/dmk_ha/bin/check_primary.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t mnt_obs.rcv
-c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
2021-07-14_15:14:09::check_primary.ksh::SetOraEnv ::INFO ==>
Environment: DB19C (/u01/app/oracle/product/19.3.0/dbhome_1)
2021-07-14_15:14:09::check_primary.ksh::MainProgram ::INFO ==> Getting
V$DATABASE.DB_ROLE for DB19C
2021-07-14_15:14:11::check_primary.ksh::MainProgram ::INFO ==> DB19C
Database Role is: PRIMARY
2021-07-14_15:14:11::check_primary.ksh::MainProgram ::INFO ==> Program
going ahead and starting requested command
2021-07-14_15:14:11::check_primary.ksh::MainProgram ::INFO ==> Script :
/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t mnt_obs.rcv
-c /u01/app/oracle/admin/DB19C/etc/rman.cfg
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::mnt_obs.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_mnt_obs_20210714_151411.log
2021-07-14_15:14:15::check_primary.ksh::CleanExit ::INFO ==> Program
exited with ExitCode : 0

On the standby server

Change archive log deletion policy on standby:

oracle@vmtestoradg2:/u01/app/oracle/local/dmk_dbbackup/rcv/oracle12/ [DB19C]
/u01/app/oracle/local/dmk_ha/bin/check_standby.ksh DB19C
"/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
change_arc_del_policy.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg"
2021-07-14_15:18:50::check_standby.ksh::SetOraEnv ::INFO ==>
Environment: DB19C (/u01/app/oracle/product/19.3.0/dbhome_1)
2021-07-14_15:18:50::check_standby.ksh::MainProgram ::INFO ==> Getting
V$DATABASE.DB_ROLE for DB19C
2021-07-14_15:18:51::check_standby.ksh::MainProgram ::INFO ==> DB19C
Database Role is: PHYSICAL STANDBY
2021-07-14_15:18:51::check_standby.ksh::MainProgram ::INFO ==> Program
going ahead and starting requested command
2021-07-14_15:18:51::check_standby.ksh::MainProgram ::INFO ==> Script :
/u01/app/oracle/local/dmk_dbbackup/bin/dmk_rman.ksh -s DB19C -t
change_arc_del_policy.rcv -c /u01/app/oracle/admin/DB19C/etc/rman.cfg
[OK]::dbi-servicesLtd::RMAN::dmk_dbbackup::DB19C::change_arc_del_policy.rcv::RMAN_retCode::0
Logfile is :
/u01/app/oracle/admin/DB19C/log/DB19C_change_arc_del_policy_20210714_151851.
log
2021-07-14_15:18:56::check_standby.ksh::CleanExit ::INFO ==> Program
exited with ExitCode : 0

Last updated