Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing multiple parameters to an RMAN script and using them on multiple lines

martinmoronoARGApr 24 2015 — edited Apr 28 2015

Hello all,

         I am trying to unify our scripts and thought about using parameter on our RMAN scripts.

Below an example of what I am referring to:

$ cat RMAN_SP0_ARCHIVELOG.cmd

# Expected Parameters:

#   #1: NB_ORA_POLICY   policy_name

#   #2: NB_ORA_SERV     media_server_name

#   #3: NB_ORA_CLIENT   client_server_name

#   #4: TAG_ARCHIVELOG  archivelog_tag_name

RUN

{

ALLOCATE CHANNEL s1 TYPE 'SBT_TAPE' PARMS="ENV=(NB_ORA_POLICY=&1, NB_ORA_SERV=&2, NB_ORA_CLIENT=&3)";

ALLOCATE CHANNEL s2 TYPE 'SBT_TAPE' PARMS="ENV=(NB_ORA_POLICY=&1, NB_ORA_SERV=&2, NB_ORA_CLIENT=&3)";

BACKUP ARCHIVELOG ALL FILESPERSET 10 TAG &4 NOT BACKED UP 1 TIMES;

DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-1' BACKED UP 1 TIMES TO DEVICE TYPE 'SBT_TAPE';

RELEASE CHANNEL s1;

RELEASE CHANNEL s2;

}

According to http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59recovery-085185.html o https://docs.oracle.com/cd/B28359_01/backup.111/b28273/rcmsynta040.htm#CHDIAFGG I should be sending the parameters either by one or other syntax:

As per the section "Example 2-128 Specifying Substitution Variables", by using the keyword USING.

rman @'/home/oracle/archivelog_bkp.cmd' USING $policy_name $media_server_name $client_server_name $archivelog_tag LOG /tmp/runbackup.out

Or by using:

rman target / << EOL

@/home/oracle/archivelog_bkp.cmd "$policy_name" "$media_server_name" "$client_server_name" "$archivelog_tag"

EOL

The first one, doesnt' work. The second one is the only one it worked for me.

Errors were:

$ rman target / @ARCHIVELOG_BKP.cmd using 'policy_name' 'media-server' 'host-name' 'archivelog-tag'

Argument     Value          Description

-----------------------------------------------------------------------------

target       quoted-string  connect-string for target database

catalog      quoted-string  connect-string for recovery catalog

nocatalog    none           if specified, then no recovery catalog

cmdfile      quoted-string  name of input command file

log          quoted-string  name of output message log file

trace        quoted-string  name of output debugging message log file

append       none           if specified, log is opened in append mode

debug        optional-args  activate debugging

msgno        none           show RMAN-nnnn prefix for all messages

send         quoted-string  send a command to the media manager

pipe         string         building block for pipe names

timeout      integer        number of seconds to wait for pipe input

checksyntax  none           check the command file for syntax errors

-----------------------------------------------------------------------------

Both single and double quotes (' or ") are accepted for a quoted-string.

Quotes are not required unless the string contains embedded white-space.

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00552: syntax error in command line arguments

RMAN-01006: error signaled during parse

RMAN-02001: unrecognized punctuation symbol "-"

It seems the "-" on the servername is making it fail.

Any of you have tried the USING keyword? Am I doing it wrong?

The one working:

$ rman target / << EOL

> $ @ARCHIVELOG_BKP.cmd using 'policy_name' 'media-server' 'host-name' 'archivelog-tag'

> EOL

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Apr 24 09:16:49 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DBNAME (DBID=1001735095)

RMAN>

RMAN> # Parametros a ingresar:

2> #   #1: NB_ORA_POLICY   policy_name

3> #   #2: NB_ORA_SERV     media-server_name

4> #   #3: NB_ORA_CLIENT   client-server_name

5> #   #4: TAG_ARCHIVELOG  archivelog-tag_name

6> RUN

7> {

8> ALLOCATE CHANNEL s1 TYPE 'SBT_TAPE' PARMS="ENV=(NB_ORA_POLICY=policy_name, NB_ORA_SERV=media-server_name, NB_ORA_CLIENT=client-server_name)";

9> ALLOCATE CHANNEL s2 TYPE 'SBT_TAPE' PARMS="ENV=(NB_ORA_POLICY=policy_name, NB_ORA_SERV=media-server_name, NB_ORA_CLIENT=client-server_name)";

10>

11> BACKUP ARCHIVELOG ALL FILESPERSET 10 TAG archivelog-tag_name NOT BACKED UP 1 TIMES;

12> DELETE NOPROMPT ARCHIVELOG UNTIL TIME 'SYSDATE-1' BACKED UP 1 TIMES TO DEVICE TYPE 'SBT_TAPE';

13>

14> RELEASE CHANNEL s1;

15> RELEASE CHANNEL s2;

16> }

using target database control file instead of recovery catalog

allocated channel: s1

channel s1: SID=426 device type=SBT_TAPE

channel s1: Veritas NetBackup for Oracle - Release 7.5 (2012020801)

allocated channel: s2

channel s2: SID=794 device type=SBT_TAPE

channel s2: Veritas NetBackup for Oracle - Release 7.5 (2012020801)

Starting backup at 24-04-2015 09:16:53

current log archived

skipping archived logs of thread 1 from sequence 544 to 665; already backed up

channel s1: starting archived log backup set

channel s1: specifying archived log(s) in backup set

input archived log thread=1 sequence=666 RECID=686 STAMP=877846201

input archived log thread=1 sequence=667 RECID=687 STAMP=877846801

input archived log thread=1 sequence=668 RECID=688 STAMP=877847402

input archived log thread=1 sequence=669 RECID=689 STAMP=877848001

input archived log thread=1 sequence=670 RECID=690 STAMP=877848601

input archived log thread=1 sequence=671 RECID=691 STAMP=877849201

input archived log thread=1 sequence=672 RECID=692 STAMP=877849802

input archived log thread=1 sequence=673 RECID=693 STAMP=877850402

input archived log thread=1 sequence=674 RECID=694 STAMP=877851001

input archived log thread=1 sequence=675 RECID=695 STAMP=877851601

channel s1: starting piece 1 at 24-04-2015 09:16:58

channel s2: starting archived log backup set

channel s2: specifying archived log(s) in backup set

input archived log thread=1 sequence=676 RECID=696 STAMP=877852201

input archived log thread=1 sequence=677 RECID=697 STAMP=877852801

input archived log thread=1 sequence=678 RECID=698 STAMP=877853402

input archived log thread=1 sequence=679 RECID=699 STAMP=877854001

input archived log thread=1 sequence=680 RECID=700 STAMP=877854601

input archived log thread=1 sequence=681 RECID=701 STAMP=877855202

input archived log thread=1 sequence=682 RECID=702 STAMP=877855801

input archived log thread=1 sequence=683 RECID=703 STAMP=877856401

input archived log thread=1 sequence=684 RECID=704 STAMP=877857002

channel s2: starting piece 1 at 24-04-2015 09:16:58

channel s1: finished piece 1 at 24-04-2015 09:17:05

piece handle=6uq562ka_1_1 tag=archivelog-tag_name comment=API Version 2.0,MMS Version 5.0.0.0

channel s1: backup set complete, elapsed time: 00:00:07

channel s1: starting archived log backup set

channel s1: specifying archived log(s) in backup set

input archived log thread=1 sequence=685 RECID=705 STAMP=877857414

channel s1: starting piece 1 at 24-04-2015 09:17:05

channel s2: finished piece 1 at 24-04-2015 09:17:06

piece handle=6vq562ka_1_1 tag=archivelog-tag_name comment=API Version 2.0,MMS Version 5.0.0.0

channel s2: backup set complete, elapsed time: 00:00:08

channel s1: finished piece 1 at 24-04-2015 09:17:12

piece handle=70q562kh_1_1 tag=archivelog-tag_name comment=API Version 2.0,MMS Version 5.0.0.0

channel s1: backup set complete, elapsed time: 00:00:07

Finished backup at 24-04-2015 09:17:12

specification does not match any archived log in the repository

released channel: s1

released channel: s2

RMAN> **end-of-file**

Thanks.

Martin

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 26 2015
Added on Apr 24 2015
6 comments
5,716 views