CONNECT sys/orcle@orcl AS SYSDBA
-- Create tablepsace to hold repository
CREATE TABLESPACE "RMAN"
DATAFILE 'C:\ORACLE\PRODUCT\10.1.0\ORADATA\DATA\RMAN01.DBF' SIZE 6208K REUSE
AUTOEXTEND ON NEXT 64K MAXSIZE 32767M
EXTENT MANAGEMENT LOCAL
SEGMENT SPACE MANAGEMENT AUTO;
-- Create rman schema owner
CREATE USER rman IDENTIFIED BY rman
TEMPORARY TABLESPACE temp
DEFAULT TABLESPACE rman
QUOTA UNLIMITED ON rman;
GRANT connect, resource, recovery_catalog_owner TO rman;
--------------------------------IF BELOW STEP FAIL THEN FOLLOW 2---------------------------------------
C:>rman catalog=rman/rman@orcl
RMAN> create catalog tablespace "RMAN";
recovery catalog created
RMAN> exit
Recovery Manager complete.
-------------------------------------------------------
Register Database
Each database to be backed up by RMAN must be registered:
C:>rman catalog=rman/rman@orcl target=sys/orcle@orcl
__________If the above step did not occur then do the below steps--2----
SQL> sho user
USER is "SYS"
SQL> GRANT connect, resource, recovery_catalog_owner TO rman;
Grant succeeded.
SQL> ho
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
U:\>rman catalog=rman/rman@orcl
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to recovery catalog database
recovery catalog is not installed
RMAN> create catalog tablespace "RMAN";
recovery catalog created
RMAN> exit
Recovery Manager complete.
U:\>rman target=sys/oracle@orcl catalog=rman/rman@orcl
Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1167611699)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
----------------
Full Backup
First we configure several persistant parameters for this instance:
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:\ORACLE\PRODUCT\10.1.0\ORADATA\rman\Backup%d_DB_%u_%s_%p';
Next we perform a complete database backup using a single command:
RMAN> run {
backup database plus archivelog;
delete noprompt obsolete;
}
Restore & Recover The Whole Database
If the controlfiles and online redo logs are still present a whole database recovery can be achieved by running the following script:
# use abort if this fails
run {
shutdown immediate;
startup mount;
restore database;
recover database;
alter database open;
}
run {
shutdown abort;
startup mount;
restore database;
recover database;
alter database open;
}
run {
startup mount;
restore database;
recover database;
alter database open;
}
run {
restore database;
recover database;
alter database open;
}
---------------
Restore & Recover A Subset Of The Database
A subset of the database can be restored in a similar fashion:
run {
sql 'ALTER TABLESPACE users OFFLINE IMMEDIATE';
restore tablespace users;
recover tablespace users;
sql 'ALTER TABLESPACE users ONLINE';
}
run {
sql 'ALTER TABLESPACE users2 OFFLINE IMMEDIATE';
restore tablespace users2;
recover tablespace users2;
sql 'ALTER TABLESPACE users2 ONLINE';
}
No comments:
Post a Comment