Author: ningoo
Version: 0.1 Modify Date:
2005-03-01
Mail: ningoo # itpub.net
test environment
Oracle Version:
9.2.0
.1.0
OS Version: Windows 2000 Server
The information of RMAN backups can be saved in a dedicated Catalog database, or in the control file of the target DB.
Initialization Parameters Control_File_Record_keep_time Specifies the number of days of the control file to save the RMAN backup information, the default is 7.
1. Use the Catalog Database Suggest Catalog on separate instance, assumes named RCVCATA. Add TableSpace Create TableSpace Rman DataFile 'Rman01.dbf' Size
20m
.; B create user create users rman identified by rman default tablespace rman; c authorized to grant RECOVERY_CATALOG_OWNER to rman; grant connect, resource to rman; C:. /> Rman catalog rman / rman @ rcvcat --- where the connection to serverRMAN catalog > CREATE CATALOG; --- Create CatalogRMAN> EXITC: /> RMAN CATALOG RMAN / RMAN @ RCVCAT TARGET / --- Connection Target Database RMAN> Register Database; --- Register Target Database Rman> Upgrade Catalog; --- Upgrade CatalogRMAN > Drop Catalog; --- Delete Catalog
2. Do not use CatalogC: /> RMAN NocatalogRecovery Manager: Release
9.2.0
. .1.0 - ProductionCopyright (c) 1995, 2002, Oracle Corporation All rights reserved.RMAN> connect target / connected to target database: OraDB (DBID = 3038703659) using target database controlfile instead of recovery catalog
3. RMAN configuration RMAN> show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK; # defaultCONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '% F'; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 1; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE SNAPSHOT CONTROLFILE NAME TO ' /opt/oracle/product/9.2.0
/dbs/snapcf_technet.f '; # Default
4. RMAN basic command lists the Schemarman> Report Schema of the database; lists the discarded backup RMAN> Report Obsolete; check backup RMAN> CrossCheck backup; Delete Expired Backup Information RMAN> Delete Expired Backup; Backup Table Space Rman> Backup TableSpace System; copy data file RMAN> Copy DataFile 1 to 'D: /oracle/oraback/datafile1.dbf'; listing backup and copy RMAN> List backup; rman> list copy; verifying whether the backup can restore RMAN> Restore Database Validate;
5. Backup script hot full --- backup.batfor / f "tokens = 1-4 delims = /" %% i in ('Date / T') Do SET DT = %% I %% J %% KRMAN NOCATALOG Target Sys / Pass @d: /backup_full.rcv> D: /oracle/oraback/backup_full_%dt%.log --- Backup_Full.rcv # Script: Bakup_Full.rcv # Desc: Backup All Database DataFile In Archive with Rman # Connect database # connect rcvcat rman / rman @ back; #connect target sys / pass; # start backup databaserun {allocate channel c1 type disk; backup full tag 'Full' filesperset 5 format 'D: / oracle / oraback /% d_Full_% T_% u_% p_% c 'database include current controlfile; sql' alter system archive log current '; backup archivelog all filesperset 5 format' D: / oracle / oraback /% d_Log_% T_% u_% p_% c '; sql' alter system Archive log current '; Release Channel C1;} # END0 Level Backup --- Backup0.batfor / F "Tokens = 1-4 Delims = /" %% I in (' Date / T ') Do SET DT = %% I %% J %% KRMAN NOCATALOG TARGET SYS / Pass @d:/backup_lvl_0.rcv> D: /oracle/oraback/backup_LEVEL0_%DT%.log --- Backup_LVL_0.RCV # Script: Bakup_lvl_0.rcv # Desc: Backup Database with Incremental Level 0 Datafil e in archive with rman # connect database # connect rcvcat rman / rman @ back; #connect target sys / pass; # start backup databaserun {allocate channel c1 type disk; backup incremental level 0 tag 'Level_0' maxsetsize = 500M format 'D: / oracle / oraback /% d_Level0_% T_% u_% p_% c 'database include current controlfile; sql' alter system archive log current '; backup archivelog all filesperset 5 format' D: / oracle / oraback /% d_Log_% T_% u_ % P_% C '; SQL' ALTER SYSTEM ARCHIVE LOG CURRENT '; Release Channel C1;} # END1 Backup --- Backup1.Batfor / F "Tokens = 1-4 Delims = /" %% I in (' Date / T '
) Do SET DT = %% I %% J %% KRMAN NOCATALOG TARGET SYS / Pass @d: /backup_lvl_0.rcv> D: /oracle/oraback/backup_level0_%dt%.log --- Backup_LVL_1.RCV # Script: Bakup_LVL_1 .rcv # desc: backup database with incremental level 0 datafile in archive with rman # connect database # connect rcvcat rman / rman @ back; #connect target sys / pass; # start backup databaserun {allocate channel c1 type disk; #backup incremental level 1 cumulative tag 'Level_1' ... backup incremental level 1 tag 'Level_1' format 'D: / oracle / oraback /% d_Level1_% T_% u_% p_% c' database include current controlfile; sql 'alter system archive log current'; backup ArchiveLog All FilesPerset 5 Format 'D: / Oracle / ORABACK /% D_LOG_% T_% U_% P_% C'; SQL 'ALTER SYSTEM Archive Log Current'; Release Channel C1;} # end Note:% C Backup Copy number % d Database Name% D At the first few days (DD)% M in this month (DD)% m in the month (mm)% f A DBID unique name, this format is C-IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII-YYYMMDD- QQ, where IIIIIIII is the DBID, YYYMMDD of the database, QQ is a 1-256 sequence% n database name, filling to the right to the maximum number of eight characters, the name of the eight characters Represents the backup set and the creation time% p The backup slice of the backup set, from 1 to the number of files created, a unique file name, represent the number% T backup set of% u_% p_% C% S backup set Time stamp% T-year monthly day format (YYYYMMDD) 6. Restore and recovery fully recovered C: /> Rman NocatalogRMAN> Connect Target / Rman> Run {Allocate Channel C1 Type Disk; Alter Database Mount; Restore Database; ALTER DATABASE Open; Release Channel C1;} Incomplete Recovery C: /> Rman NocatalogRMan> Connect Target / Rman> Run {Allocate Channel C1 Type Disk; Set Until Time '
2005-01-24
15:20:00 '; #set Until Sequence 120 Thread 1; ALTER DATABASE; Restore Database; Recover Database; ALTER DATABASE RESETLOGS Release Channel C1;} Recovery Control File You can use the following method, restore the backup film control file in RMAN Restore ControlFile from backuppiecefile; if you are automatic backup of 9i, you can use the following method controlfile from autobackup; however, if the control file is all lost, you need to specify DBID, such as SET DBID =? The default format of the automatic backup control file is% F, This format is c-iiiiiiiiiii-yyyymmdd-qq, where iiiiiiiiii is DBID special recovery if the backup information in Catalog and Control file is lost, you can recover from backup set by DBMS_BACKUP_RESTORE packages Declare DevType Varchar2 (100) DONE boolean; recid number; stamp number; fullname varchar2 (100); begin devtype: = dbms_backup_restore.deviceallocate (type => '', ident => 't1'); dbms_backup_restore.restoresetdatafile; dbms_backup_restore.restorecontrolfileto ( 'd: / oracle / o
Radata / TEST / control01.ctl '); dbms_backup_restore.restorebackuppiece (' D: / oracle / oraback / C-3965546666-20050228-00 ', DONE => done); sys.dbms_backup_restore.deviceDeallocate; End;
/ Restore 0 level backup file declare devtype varchar2 (100) done boolean; recid number; stamp number; fullname varchar2 (100); begin devtype: = dbms_backup_restore.deviceallocate (type => '', ident => 't1'); sys .dbms_backup_restore.restoretdatafile; sys.dbms_backup_restore. restoredataFileto (DFNumber => 01, Toname => 'D: / Oracle / O
Radata / test / system01.dbf '); sys.dbms_backup_restore.restoredAtaFileto (DFNumber => 02, Toname =>' D: / Oracle / O
Radata / TEST / UNDOTBS01.DBF '); ... sys.dbms_backup_restore.restoreBackupPiece (done => done, handle =>' D: / oracle / oraback / TEST_LEVEL0_20050228_46GDTAV8_1_1 ', params => null); sys.dbms_backup_restore.restoreBackupPiece (done = > done, handle => 'D: / oracle / oraback / TEST_LEVEL0_20050228_47GDTB28_1_1', params => null); sys.dbms_backup_restore.deviceDeallocate; END; / restore the backup file level 1 declare devtype varchar2 (100) done boolean; recid number; stamp Number; fullname varcha2 (100); begindevType: = sys.dbms_backup_restore.deviceAllocate (Type => '', Ident => 'T1');
Sys.dbms_backup_restore.applysetdatafile; sys.dbms_backup_restore.ApplyDataFileto (DFNumber => 02, Toname => 'D: / Oracle / O
Radata / test / system01.dbf ');
Sys.dbms_backup_restore.ApplyDataFileto (DFNumber => 02, Toname => 'D: / Oracle / O
Radata / test / undotbs01.dbf ');
...
sys.dbms_backup_restore.applyBackupPiece (done => done, handle => 'D: / oracle / oraback / TEST_LEVEL1_20050301_4AGE6UDI_1_1', params => null); sys.dbms_backup_restore.deviceDeallocate;
END; /
RESTORE archiving log declare devType varcha2 (100) Done Boolean; Recid Number; Stamp Number; Fullname Varchar2 (100); Begin
DevType: = sys.dbms_backup_restore.deviceAllocate (Type => ', Ident =>' T1 ');
sys.dbms_backup_restore.restoreSetArchivedLog; sys.dbms_backup_restore.restoreArchivedLogRange; sys.dbms_backup_restore.restoreBackupPiece (done => done, handle => 'D: / oracle / oraback / TEST_LOG_20050228_48GDTB5K_1_1', params => null); sys.dbms_backup_restore.deviceDeallocate;
END; /
NINGOO collection, reprint, please indicate http://blog.9cbs.net/ningoo