12 January 2010

How to use RNAM succesfully on the commandline

First create a user in the database and giver the necessary grants:

CREATE USER rman IDENTIFIED BY rman
TEMPORARY TABLESPACE temp
DEFAULT TABLESPACE rman
QUOTA UNLIMITED ON rman;

grant dba,connect,resource, sysdba to rman;

grant RECOVERY_CATALOG_OWNER to rman;


Then logon to RMAN:


Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

H:\>E:

E:\oracle\ora92\bin>rman catalog=rman/rman@rmandb

Recovery Manager: versie 9.2.0.1.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

Verbonden met herstelcatalogusdatabase.



Then create a catalog:

RMAN> create catalog tablespace "RMAN";

Herstelcatalogus is aangemaakt.

RMAN> exit


Recovery Manager is voltooid.

E:\oracle\ora92\bin>


Then Register Database:

E:\rman catalog=rman/rman@rmandb target=sys/visor@boprd

RMAN> register database;

RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure channel device type disk format 'D:\Backup\Backup_%d_%T_%U';
RMAN> configure controlfile autobackup format for device type disk to 'D:\Backup\B_%d_%F';


NOTE: 'F:\' is a backup location where AUTOBACKUP controlfile or spfile created and "%d_%T_%U" is format.


'Format_String' clause

The formatting of this information varies by platform.

Syntax:

  %c  The copy number of the backup piece within a set of duplexed
      backup pieces. If you did not duplex a backup, then this variable
      is 1 for backup sets and 0 for proxy copies.
      If one of these commands is enabled, then the variable shows the
      copy number. The maximum value for %c is 256.

  %d  The name of the database.

  %D  The current day of the month (in format DD)

  %F  Combination of DBID, day, month, year, and sequence into a unique
      and repeatable generated name.

  %M  The month (format MM)

  %n  The name of the database, padded on the right with x characters
      to a total length of eight characters. (AKA: Porn star alias name)
      For example, if the scott is the database name, %n= scottxxx.

  %p  The piece number within the backup set. This value starts at 1
      for each backup set and is incremented by 1 as each backup piece
      is created. Note: If you specify PROXY, then the %p variable must
      be included in the FORMAT string either explicitly or implicitly within %U.

  %s  The backup set number. This number is a counter in the control file that
      is incremented for each backup set. The counter value starts at 1 and is
      unique for the lifetime of the control file. If you restore a backup
      control file, then duplicate values can result.
      Also, CREATE CONTROLFILE initializes the counter back to 1.

  %t  The backup set time stamp, which is a 4-byte value derived as the
      number of seconds elapsed since a fixed reference time.
      The combination of %s and %t can be used to form a unique name for
      the backup set.

  %T  The year, month, and day (YYYYMMDD)

  %u  An 8-character name constituted by compressed representations of
      the backup set number and the time the backup set was created.

  %U  A convenient shorthand for %u_%p_%c that guarantees uniqueness in
      generated backup filenames.
      If you do not specify a format, RMAN uses %U by default.

  %Y  The year (YYYY)

  %%  Specifies the '%' character. e.g. %%Y translates to %Y.


"We don't want to go back to tomorrow, we want to go forward" - Dan Quale


Then Create the backup as follows:

Backup maken met volgende commando:

run {
  backup database plus archivelog;
  delete noprompt obsolete;
    }



Obsolete command below:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\ora92\database\SNCFBOPRD.ORA';
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\ora92\database\SNCFBOPRD.ORA';

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of configure command at 08/05/2008 12:37:18
RMAN-03014: implicit resync of recovery catalog failed
RMAN-03009: failure of full resync command on default channel at 08/05/2008 12:3
7:18
ORA-01580: Fout bij het aanmaken van backup van control-bestand E:\ORACLE\ORA92\SNCFBOPRD.ORA.
ORA-27040: skgfrcre: fout bij aanmaken, bestand kan niet worden aangemaakt.
OSD-04002: Kan bestand niet openen.
O/S-Error: (OS 3) The system cannot find the path specified.
Solution for this problem, login on to target DB in SQLPLUS on the target Database with sys as sydba and then execute command shown below for path of the target server:


SQL> EXECUTE SYS.DBMS_BACKUP_RESTORE.CFILESETSNAPSHOTNAME('D:\oracle\ora92\database\SNCFBOPRD.ORA');

EXECUTE SYS.DBMS_BACKUP_RESTORE.CFILESETSNAPSHOTNAME('D:\ORACLE\ora92\DATABASE\SNCFBOPRD.ORA');


Command for backup:


run {
allocate channel ch1 type disk format 'E:\backup\full_backup_%d_%s_%t';
backup full tag FULL_DB
( database include current controlfile)
( archivelog from time 'sysdate-1' all delete input);
release channel ch1;
}


Commando for restore:

run {
shutdown immediate;
startup mount;
set until time '2004-07-14 10:00:00';
restore database;
recover database;
alter database open resetlogs;
}




oracle rman script to make a cold backup of 9i database
-------------------------------------------------------

# 9i.rcv
# This is an AUTOMATICALLY GENERATED RMAN script for Oracle 9 to
# cold backup the 9i database including controlfile, datafiles and
# archive redo logs to disk (no Legato tape option is available yet).
# No recovery catalog is currently used, due to current semaphore
# limitations on some machines.

shutdown immediate;
startup mount;
run {

allocate channel c1 type disk;
backup
        tag Full_9i_daily
        format '/oracle/9i/full/9i/Full_%d_%s_%p_%t'
        (database);
release channel c1;

configure controlfile autobackup format for device type disk to '/oracle/9i/full/9i/Auto_Ctrl_%F';
configure controlfile autobackup on;

allocate channel c1 type disk;
backup
        format '/oracle/9i/full/9i/Archive_%d_%s_%p_%t'
        (archivelog all );
release channel c1;

configure controlfile autobackup off;

}
startup;


alternative script for cold backup with rman:


replace script 'rman_daily_backup' {
shutdown immediate;
startup mount;
allocate channel dev1 type disk format '/images/rman_%s.bak';
backup database include current controlfile;
alter database open;
release channel dev1;
}
   
Share:

0 reacties:

Post a Comment