Coskan’s Approach to Oracle

July 30, 2007

Nice RMAN command for double checkers or careless ones

Filed under: Backup/Recovery — coskan @ 2:38 pm

Suppose that, you have a RMAN command file and you are sure about the syntax of the commands you wrote. You scheduled it to run at midnight ( without testing on any test server) on production system, and when you came to office next day you saw that the script failed due to a syntax error. To avoid this kind of errors RMAN of 10G R2 has a new feature to check the syntax before you run them. The command is CHECKSYNTAX, what it does is only check the syntax of the commands you give as an input, also you do not need any target connection to run this command. Lets see how it works

Usage is simple

C:\Documents and Settings\cgundogar>rman checksyntax
Recovery Manager: Release 10.2.0.1.0 – Production on Pzt Tem 30 17:28:29 2007Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN> backup database;The command has no syntax errors

RMAN> backup datafile;

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

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

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

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found “;”: expecting one of: “double-quoted-string, integer, single-quoted-string”

RMAN-01007: at line 1 column 16 file: standard input

for command files you only give the input file and take the result set;

suppose that your command file is like below

run {
allocate channel ch1 type disk;
restore archivelog ;
}

C:\Documents and Settings\cgundogar>rman checksyntax
Recovery Manager: Release 10.2.0.1.0 – Production on Pzt Tem 30 17:28:29 2007Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN> @rman.txt

RMAN> run {

2> allocate channel ch1 type disk;

3> restore archivelog ;

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

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

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

RMAN-00558: error encountered while parsing input commands

RMAN-01009: syntax error: found “;”: expecting one of: “all, from, high, like, logseq, low, scn, sequence, time, until”

RMAN-01007: at line 3 column 20 file: rman.txt

When you give the correct command the output will be like below

C:\Documents and Settings\cgundogar>rman checksyntax
Recovery Manager: Release 10.2.0.1.0 – Production on Pzt Tem 30 17:28:29 2007Copyright (c) 1982, 2005, Oracle. All rights reserved.RMAN> @rman.txt

RMAN> run {

2> allocate channel ch1 type disk;

3> restore archivelog all;

4> }

The cmdfile has no syntax errors

RMAN>

RMAN> **end-of-file**

References Used:

10G R2 Documentation – Backup and Recovery Basics

The Silver is the New Black Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 199 other followers