RMAN script gives error

Hi,

I have the following RMAN incremental shell script:

# !/bin/bash

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=ORCL
export PATH=$PATH:${ORACLE_HOME}/bin

rman target=/ << EOF
run {
allocate channel d1 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
allocate channel d2 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
allocate channel d3 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';

backup incremental level 1 tag Daily_Diff_Backup
    format '/u01/app/oracle/backup/Daily_%T_L1_%db_df_%U_%t';

sql 'alter system archive log current';
sql 'alter system archive log current';
backup tag ORCL_ARCHIVE
       archivelog all 
       format '/u01/app/oracle/backup/al_%t_%s_p_ARCHIVE' 
       delete all input;

backup tag ORCL_CONTROL
           current controlfile 
           format '/u01/app/oracle/backup/cf_%t_%s_p_CONTROL';

crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;

release channel d1;
release channel d2;
release channel d3;
}
EXIT
EOF

And, when I run it, I am getting errors like:

$ ./rman.sh
Recovery Manager: Release 11.2.0.1.0 - Production on Tue Dec 17 12:17:20 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CTSDEV (DBID=1899476973)
RMAN>
RMAN> 2> 3> 4> 5> 6> 7> 8> 9>
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: "archivelog, as, auxiliary, backupset, backup, 
RMAN-01007: at line 10 column 61 file: standard input

 
RMAN>
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: ";"
RMAN-01008: the bad identifier was: d1
RMAN-01007: at line 2 column 17 file: standard input
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: ";"
RMAN-01008: the bad identifier was: d2
RMAN-01007: at line 1 column 17 file: standard input
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: ";"
RMAN-01008: the bad identifier was: d3
RMAN-01007: at line 1 column 17 file: standard input
RMAN>
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 
RMAN-01007: at line 1 column 1 file: standard input

Could anyone tell me what error I have made in the script?

The following statement is incomplete:

backup incremental level 1 tag Daily_Diff_Backup
    format '/u01/app/oracle/backup/Daily_%T_L1_%db_df_%U_%t';

Backup what :)? Database?
(in the example below "s" is your script name)

bash-3.00$ rman checksyntax @s

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Dec 20 14:34:22 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

RMAN> run {
2> allocate channel d1 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
3> allocate channel d2 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
4> allocate channel d3 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
5>
6> backup incremental level 1 tag 'Daily_Diff_Backup'
7>     format '/u01/app/oracle/backup/Daily_%T_L1_%db_df_%U_%t';
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: "archivelog, as, backup, backupset, blocks, channel, check, comma, copy, copies, controlfilecopy, cumulative, current, database, datafile, datafilecopy, device, diskratio, db_recovery_file_dest, db_file_name_convert, duration, filesperset, for, format, full, force, incremental, keep, (, maxsetsize, nochecksum, noexclude, nokeep, not, proxy, pool, reuse, recovery, skip, spfile, setsize, tablespace, tag, to, validate"
RMAN-01007: at line 7 column 57 file: s

Added the keyword database:

bash-3.00$ rman checksyntax @s

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Dec 20 14:34:52 2013

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

RMAN> run {
2> allocate channel d1 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
3> allocate channel d2 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
4> allocate channel d3 type disk FORMAT '/u01/app/oracle/backup/Daily_%U_%t';
5>
6> backup incremental level 1 tag Daily_Diff_Backup
7>   database
8>     format '/u01/app/oracle/backup/Daily_%T_L1_%db_df_%U_%t';
9>
10> sql 'alter system archive log current';
11> sql 'alter system archive log current';
12> backup tag ORCL_ARCHIVE
13>        archivelog all
14>        format '/u01/app/oracle/backup/al_%t_%s_p_ARCHIVE'
15>        delete all input;
16>
17> backup tag ORCL_CONTROL
18>            current controlfile
19>            format '/u01/app/oracle/backup/cf_%t_%s_p_CONTROL';
20>
21> crosscheck archivelog all;
22> delete noprompt expired archivelog all;
23> crosscheck backup;
24> delete noprompt expired backup;
25>
26> release channel d1;
27> release channel d2;
28> release channel d3;
29> }
30>
The cmdfile has no syntax errors

Recovery Manager complete.
1 Like

Awesome radoulov :slight_smile: for pointing out the glitch.

By the way, the following query is repeated in the script

sql 'alter system archive log current';

Is that by mistake again? Is just calling one time enough?

One should be sufficient, more do not harm.