viernes, 25 de septiembre de 2009

RMAN Creacion Scripts

CREATE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;
}

CREATE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';

RUN { EXECUTE GLOBAL SCRIPT full_backup; }

PRINT GLOBAL SCRIPT full_backup;

LIST GLOBAL SCRIPT NAMES;
LIST ALL SCRIPT NAMES; # Global and local scripts.

REPLACE GLOBAL SCRIPT full_backup
{
BACKUP DATABASE PLUS ARCHIVELOG;
DELETE FORCE NOPROMPT OBSOLETE;
}

REPLACE GLOBAL SCRIPT full_backup FROM FILE 'full_backup.txt';

DELETE GLOBAL SCRIPT 'full_backup';



Creating Local-Stored Scripts

Script Windows

RMAN> create script full_disk_db
2> {
3> allocate channel c1 type disk
4> format 'c:\oracle\flash\loc1\rman_%U.rman';
5> backup
6> database
7> include current controlfile;
8> release channel c1;
9> }

Creating a Global-Stored Script

RMAN> create global script gs_arc_disk_bkup
2> comment 'Global Script to Backup Arc Logs Delete Input'
3> {
4> allocate channel c1 type disk
5> format 'C:\oraback\%U.rman';
6> backup
7> archivelog
8> all
9> delete input;
10> release channel c1;
11> }

Updating Stored Scripts

RMAN> replace script full_disk_db
2> {
3> allocate channel c1 type disk
4> format 'c:\backup\rman_%U.rman';
5> backup
6> database
7> include current controlfile;
8> release channel c1;
9> }

Commenting on Stored Scripts

RMAN> create script full_disk_db
2> comment 'Full Backup as Backupset to Disk'
3> {
4> allocate channel c1 type disk
5> format 'c:\backup\rman_%U.rman';
6> backup
7> database
8> include current controlfile;
9> release channel c1;
10> }

Displaying Stored Scripts

RMAN> print script full_disk_db;
The output, in this case, comes back as follows:
printing stored script: full_disk_db
{allocate channel c1 type disk
format 'c:\backup\rman_%U.rman';
backup
database
include current controlfile;
release channel c1;
}

RMAN> print global script full_disk_db;

RMAN> list script names;

EXAMPLE

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Sep 25 10:00:02 2009

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

connected to target database: LETODB (DBID=3814852239)

RMAN> connect catalog rman/rman@cat10g;

connected to recovery catalog database

RMAN> list script names;

List of Stored Scripts in Recovery Catalog

No scripts in recovery catalog

RMAN> list global script names;

Dropping Stored Scripts

RMAN> delete script delete_arc_logs;


You have two scripts of the same name—delete_arc_logs—one local and one global. You
want to execute the global script, not the local one.

Solution
To execute the global script, you call that script with the clause global before it, as shown in
the following RMAN command:

RMAN> run { execute global script delete_arc_logs; }

Converting Stored Scripts to Files

RMAN> print script delete_arc_logs to file 'c:\tools\delete_arc_logs.rman';

Creating or Replacing a Stored Script from a File

RMAN> replace script delete_arc_logs from file 'c:\tools\delete_arc_logs.rman';

Passing Parameters to Stored Scripts

RMAN> replace script delete_archive_log { delete noprompt archivelog sequence &1 ; }

RMAN> replace script delete_archive_log { delete &2 archivelog sequence &1 ; }

Creating a Parameterized Command File Script

Problem

You want to create an RMAN command file script that can accept a parameter.

Solution

In Oracle Database 11g, to create a RMAN command file in Unix (or Windows) that can accept
a parameter, you simply create a file like this:
{ delete noprompt archivelog sequence &1 ; }


C:\tools>rman target=/ @c:\tools\del_arc_logs_pattern.rman using '2007_05_11'
Recovery Manager: Release 11.1.0.4.0 - Beta on Fri May 11 14:55:36 2007
Copyright (c) 1982, 2006, Oracle. All rights reserved.
connected to target database: MOBDB11 (DBID=406156306)
RMAN> { delete archivelog like '%2007_05_11%' ; }
2>
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
deleted archived log
archived log file name=C:\ORACLE\FLASH\MOBDB11\ARCHIVELOG\2007_05_11\O1_MF_1_38_➥
348WK5OZ_.ARC RECID=4 STAMP=622287589
deleted archived log
archived log file name=C:\ORACLE\FLASH\MOBDB11\ARCHIVELOG\2007_05_11\O1_MF_1_39_➥
348WKBQX_.ARC RECID=5 STAMP=622287595
deleted archived log
archived log file name=C:\ORACLE\FLASH\MOBDB11\ARCHIVELOG\2007_05_11\O1_MF_1_40__➥
348WKCB8_.ARC RECID=6 STAMP=622287595
deleted archived log
archived log file name=C:\ORACLE\FLASH\MOBDB11\ARCHIVELOG\2007_05_11\O1_MF_1_41__➥
348WKJ6C_.ARC RECID=7 STAMP=622287600
Deleted 4 objects

No hay comentarios: