RMAN checksyntax function
Posted by John Hallas on December 29, 2016
I was looking at the RMAN DEBUG options and came across the CHECKSYNTAX function which I had not used before.
Firstly a quick recap on the DEBUG option.
This can be called using the following syntax
rman target / catalog rman12g1/xxxx@rmancat debug trace=rmantrace.log cmdfile=backup.rcv
or
rman target / catalog rman12g1/xxxx@rmancat debug trace=rmantrace.log then run RMAN> @backup.rcv (or just type in your run block of commands)
There are a number of options to DEBUG and one of the error messages lists them out quite neatly
RMAN-01009: syntax error: found "integer": expecting one of: "all, duplicate, recover, restore, resync, sql"
To be honest if I was tracing I would just stick with the DEBUG=ALL format. The DEBUG=SQL gives all the internal commands that RMAN calls and could be interesting if you were doing a deep dive into RMAN functionality
Anyway, back to the CHECKSYNTAX option.
I run it against the edited version of the command file used above
rman target / catalog rman12g1/xxxx@rmancat checksyntax cmdfile=backup.rcv Recovery Manager: Release 12.1.0.2.0 - Production on Wed Dec 28 10:22:20 2016 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. connected to target database: T12TEST (DBID=1543168240) connected to recovery catalog database
RMAN> run { 2> sql "alter session set nls_date_format=''YYYY-MM-DD:HH24:MI:SS''"; 3> allocate channel c1 device type disk format '/app/oracle/backup/backup_db_%d_S_%s_P_%p_T_%t'; 4> allocate channel c2 device type disk format '/app/oracle/backup/backup_db_%d_S_%s_P_%p_T_%t'; 5> backup database INCLUDE CURRENT CONTROLFILEs; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "identifier": expecting one of: "controlfile" RMAN-01008: the bad identifier was: CONTROLFILEs RMAN-01007: at line 6 column 33 file: backup.rcv
Note the file backup.rcv has a blank line as the first line which confuses the line numbering
Pretty neat. I edit the file and put a different error in, a much more common missing semi-colon
RMAN> run { 2> sql "alter session set nls_date_format=''YYYY-MM-DD:HH24:MI:SS''"; 3> allocate channel c1 device type disk format '/app/oracle/backup/backup_db_%d_S_%s_P_%p_T_%t'; 4> allocate channel c2 device type disk format '/app/oracle/backup/backup_db_%d_S_%s_P_%p_T_%t' 5> backup RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-00558: error encountered while parsing input commands RMAN-01009: syntax error: found "backup": expecting one of: "auxiliary, connect, format, maxopenfiles, maxpiecesize, parms, rate, send, to, comma, ;" RMAN-01007: at line 6 column 1 file: backup.rcv
Overall not a mind-shatteringly exciting find but something that might be of use one day
NormanDunbar said
Morning John.
I’m pretty sure I left some information about debug and trace RMAN command line parameters on the wiki!
Happy New Year.
Cheers,
Norm.
John Hallas said
Just had a look and you did indeed Norm. However no mention of checksyntax. Have a good 2017
Frank Gordon said
Hello,
Its great except it doesn’t catch errors like
BACKUP DATABASE FORMAT ‘C:\NON_EXISTENT_DIRECTORY\%U.BKP’;
BACKUP DATABASE FORMAT ‘/backups/NON_EXISTENT_DIRECTORY/%U.bkp’;
The only time you know these will fail will be when its run for real.
!
Nit-picking I know.
Frank
John Hallas said
True Frank, but it is a syntax checker and the syntax is correct.
zhwsh said
if you using 10g:
$ cat r.rman
run
{
allocate channel c1 device type DISK;
allocate channel c2 device type DISK;
release channel c1;
release channel c2;
}
$ rlrman checksyntax
Recovery Manager: Release 10.2.0.4.0 – Production on Fri Dec 30 10:04:06 2016
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: STATISTI (DBID=3581654166)
RMAN> @ r.rman
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found “identifier”: expecting one of: “allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate”
RMAN-01008: the bad identifier was: r
RMAN-01007: at line 1 column 2 file: standard input
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found “dot”: expecting one of: “allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate”
RMAN-01007: at line 1 column 3 file: standard input
RMAN> @r.rman
RMAN> run
2> {
3> allocate channel c1 device type DISK;
4> allocate channel c2 device type DISK;
5> release channel c1;
6> release channel c2;
7> }
The cmdfile has no syntax errors
RMAN>
RMAN> **end-of-file**
–between @ and r.rman have not bloank. I take me about 2 hours.^_^
John Hallas said
Interesting but not an issue with Oracle per se.