Operating System - HP-UX
1819796 Members
3106 Online
109607 Solutions
New Discussion юеВ

shell script using Oracle's RMAN

 
SOLVED
Go to solution
Jian Wu
New Member

shell script using Oracle's RMAN

I wrote a shell script to delete the expired archive logs from the RMAN repository. I used the command:
delete expired archivelogs all;

The command return 2 different results:

1) when it find expired archivelogs, it ask for confirmation:

Do you really want to delete the above objects (enter YES or NO)?

2) when it didn't find expired archivelogs, it return a message:

specification does not match any archive log in the recovery catalog

My script look like this:

rman target sys/pwd@PRCV catalog rman/rman@DRMAN <allocate channel for delete type disk;
delete expired archivelog all;
YES
release channel;
EOF

I worked fine if it find expired archivelogs. Otherwise it returned error message because it couldn't recognize "YES". How to make the script work under either conditions?

Any help on this will be greatly appreciated.
7 REPLIES 7
Solution

Re: shell script using Oracle's RMAN

Try:

delete noprompt expired archivelogs all;

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Jian Wu
New Member

Re: shell script using Oracle's RMAN

Duncan: Thanks, but it didn't work. I don't think "noprompt" is supported by RMAN. Since the "delete ..." command is excuted within RMAN, it must be supported by RMAN. I asked Oracle if there is a way to suppress the confirmation, and the anwser is none. What I have in mind is to build a condition, such as if it returns records do "YES", otherwise, skip it. But don't know how to do it within the context of RMAN.
Michael Schulte zur Sur
Honored Contributor

Re: shell script using Oracle's RMAN

Hi,

You may try with force.

Michael

FORCE
Deletes specified files (whether or not they exist on the media) and removes repository records. RMAN ignores any I/O errors for the deleted objects. RMAN displays the number of deleted objects at the end of the job.

NOPROMPT
Deletes specified files without first listing the files or prompting for confirmation. The DELETE NOPROMPT command still displays each item as it is deleted. By default, DELETE displays files and then prompts for confirmation. If the user confirms, then RMAN shows each item as it is deleted. If you are running commands from a command file, then NOPROMPT is the default.

EXPIRED
Removes only files whose status in the repository is EXPIRED. RMAN marks backups and copies as expired when you run a CROSSCHECK command and the files are absent or inaccessible. To determine which files are expired, run a LIST EXPIRED command.

Note: Beginning in Oracle9i, RMAN's default behavior is to prompt for confirmation when you run DELETE EXPIRED. In prior releases, RMAN did not prompt.

BACKUP
Deletes backup sets, backup pieces, and proxy copies. By default, RMAN deletes backups of the whole database. Specify the EXPIRED option to remove only backups that are marked EXPIRED in the repository. The KEY column of the LIST output indicates the primary key usable in the CHANGE and DELETE commands.

COPY
Deletes datafile copies, archived redo logs, and image copies of archived redo logs. By default, DELETE ... COPY removes copies of all files in the database. Specify the EXPIRED option to remove only copies that are marked EXPIRED in the repository

Michael Schulte zur Sur
Honored Contributor

Re: shell script using Oracle's RMAN

Hi,

this should work too:
delete noprompt expired archivelog all;


Michael
Jian Wu
New Member

Re: shell script using Oracle's RMAN

My situation is the actual files were deleted from the OS. Here I only need to remove the registry from the repository.
When I do "noprompt", I got:
RMAN> delete noprompt expired archivelogs all;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01005: syntax error: found "identifier": expecting one of: "archivelog, backup, backuppiece, ba
ckupset, copy, controlfilecopy, datafilecopy, proxy"
RMAN-01008: the bad identifier was: archivelogs
RMAN-01007: at line 2 column 26 file: standard input
Michael Schulte zur Sur
Honored Contributor

Re: shell script using Oracle's RMAN

Jian,

in case you didn't notice. In my last post the archivelog has no s at the end. ;-)

Michael
Jian Wu
New Member

Re: shell script using Oracle's RMAN

Michael: Thanks, you are absolutely right! It worked after I corrected the error. It's amazing that Oracle analyst didn't know the option "noprompt". Thanks again.

Duncan - your response was actually correct, except that there is an extra "s" after archivelog. Thanks!