Oracle 11g has a new feature. Replace the variable in the RMAN script. Today, I did a small experiment on the server and tried this feature. Although some errors have been made, all of them have been solved! I feel that this feature is still good. Let's start with the question below.
1. Create a directory for storing scripts and backup files
$ Cd/u01
$ Mkdir-p oraclescripts/backup/dynamic
$ Mkdir/u01/backupfiles
2. Create related scripts
$ Cd/u01/oraclescripts/backup/dynamic
$ Vi backup. cmd
Add the following command:
# Backup. cmd
Connect target/
Run {
Backup datafile 5
Tag = & 1
Format '& 2 ';
}
Exit;
This is an RMAN command, which will be called using a shell script later. The following is a shell script:
$ Vi nightly_backup.sh
Add the following command:
#! /Bin/bash
Tag = $1
Format = $2
Rman @ backup. cmd using $ tag $ format
OK, let's execute this shell script,
$ Sh nightly_backup.sh testtag \ '/u01/backupfiles/file5.bk \'
I use two parameters. The first is the Tag, and the second is the path to be backed up. After obtaining two parameters, the shell script executes @ backup. when cmd is used, the two parameters are passed in to & 1 and & 2. In this experiment, we back up the data file no. 5. You can customize the backup policy.
Although this experiment is small, it is also difficult for me to do it. google has done it several times. For example, when passing parameters, we need to use \ escape and add the = sign after the tag. In short, although the experiment is small, but I have learned a lot. Here I will share with you, hoping to help new users. My references are chapter 4, section 10th, in RMAN Recipes for Oracle Database 11g.
RMAN Recipes for Oracle Database 11g pdf download see