Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

DBMS_BACKUP_RESTORE.DBMS_BACKUP_RESTORE is used for recovery in special cases

2025-02-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Generally as follows: the system crashes, rman uses control files, no control files are used for automatic backup, and now there is only the last full backup (including control files in the backup), as well as its incremental backup and regular file backup.

In general, regular RMAN cannot be used to restore, because the backup control file in this full backup does not contain the backup information. When rman uses the control file backup, the backup control file is backed up first.

Back up other information later

Background knowledge

In Oracle versions later than 816, Oracle provides a package: the DBMS_BACKUP_RESTORE.DBMS_BACKUP_RESTORE package is created by two scripts, dbmsbkrs.sql and prvtbkrs.plb. These two packages are called when the catproc.sql script runs. So every database has this package, which is the interface of IO operation between Oracle server and operating system. Called directly by the recovery manager. And it is said that the functions of these two scripts are built into some library files of Oracle.

Thus, we can call these package in the case of database nomount to achieve our recovery purpose. There are detailed documentation in the dbmsbkrs.sql and prvtbkrs.plb scripts

The key contents are:

FUNCTION deviceAllocate (

Type IN varchar2 default NULL

, name IN varchar2 default NULL

, ident IN varchar2 default NULL

, noio IN boolean default FALSE

, params IN varchar2 default NULL)

RETURN varchar2

PROCEDURE restoreControlfileTo (cfname IN varchar2)

PROCEDURE restoreDataFileTo (dfnumber IN binary_integer

, toname IN varchar2 default NULL)

SQL > startup force nomount

SQL >

DECLARE

Devtype varchar2 (256)

Done boolean

BEGIN

-- assign a device channel. If you use an operating system file, the type will be empty. If you are restoring from the tape, use "sbt_tape".

Devtype:=sys.dbms_backup_restore.deviceAllocate (type= >'', ident= > 't1')

-- indicates the start of restore

Sys.dbms_backup_restore.restoreSetDatafile

-- indicate the target storage location of the file to be restored

Sys.dbms_backup_restore.restoreControlfileTo (cfname= > 'ORACLEORADATAFENETCONTROL01.CTL')

-- sys.dbms_backup_restore.restoreControlfileTo (cfname= > 'DMOACLEORADATAFENETCONTROL02.CTL')

-- sys.dbms_backup_restore.restoreControlfileTo (cfname= > 'DMOACLEORADATAFENETCONTROL03.CTL')

-specify the location of the backup set

Sys.dbms_backup_restore.restoreBackupPiece (done= > done,handle= > 'DRA9I6095222264.RMAN, params= > null)

-- release channel

Sys.dbms_backup_restore.deviceDeallocate

END

The corresponding relationship between file# and name can be obtained from this statement.

Select 'sys.dbms_backup_restore.restoreDatafileTo (dfnumber= >' | | file# | |

', toname= >' | | chr (39) | | name | | chr (39) | |');'

'sys.dbms_backup_restore.applySetDatafile (dfnumber= >'| | file# | |

', toname= >' | | chr (39) | | name | | chr (39) | |');'

From v$datafile

Execute the following statement in the nomount state

Restore the statement of a level 0 backup

DECLARE

Devtype varchar2 (256)

Done boolean

BEGIN

Devtype:=sys.dbms_backup_restore.deviceAllocate (type= >'', ident= > 't1')

Sys.dbms_backup_restore.restoreSetDatafile

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 1 Magneto Toname = > 'Dviso ORACLEORADATAFENETSYSTEM01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 2Meditamee = > 'Dviso ORACLEORADATAFENETUNDOTBS01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 3 recordtoname = > 'DVV ORACLEORADATAFENETCWMLITE01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 4 training toname = > 'DVV ORACLEORADATAFENETDRSYS01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 5 training toname = > 'DVOR ORLAADATAFENETEXAMPLE01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 6 recordtoname = > 'DVV ORACLEORADATAFENETINDX01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 7 training toname = > 'DVV ORACLEORADATAFENETODM01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 8 training toname = > 'Dviso ORADATAFENETTOOLS01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 9 recordtoname = > 'DVOR ORADATAFENETUSERS01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 10 recordtoname = > 'DVR ORACLEORADATAFENETXDB01.DBF')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 11 training toname = > 'DVR ORACLEORADATAFENETBJIC.ORA')

Sys.dbms_backup_restore.restoreDatafileTo (dfnumber= > 12 recordtoname = > 'DVOR ORADATAFENETPM' USERS.DBF')

Sys.dbms_backup_restore.restoreBackupPiece (done= > done,handle= > 'DRA9I6095222264.RMAN, params= > null)

Sys.dbms_backup_restore.deviceDeallocate

END

Restore statements for incremental backups

DECLARE

Devtype varchar2 (256)

Done boolean

BEGIN

Devtype:=sys.dbms_backup_restore.deviceAllocate (type= >'', ident= > 't1')

Sys.dbms_backup_restore.applySetDatafile

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 1 Magneto Toname = > 'Dviso ORACLEORADATAFENETSYSTEM01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 2Meditamee = > 'Dviso ORACLEORADATAFENETUNDOTBS01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 3 recordtoname = > 'DVV ORACLEORADATAFENETCWMLITE01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 4 training toname = > 'DVV ORACLEORADATAFENETDRSYS01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 5 training toname = > 'DVOR ORLAADATAFENETEXAMPLE01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 6 recordtoname = > 'DVV ORACLEORADATAFENETINDX01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 7 training toname = > 'DVV ORACLEORADATAFENETODM01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 8 training toname = > 'Dviso ORADATAFENETTOOLS01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 9 recordtoname = > 'DVOR ORADATAFENETUSERS01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 10 recordtoname = > 'DVR ORACLEORADATAFENETXDB01.DBF')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 11 training toname = > 'DVR ORACLEORADATAFENETBJIC.ORA')

Sys.dbms_backup_restore.applySetDatafile (dfnumber= > 12 recordtoname = > 'DVOR ORADATAFENETPM' USERS.DBF')

Sys.dbms_backup_restore.applyBackupPiece (done= > done,handle= > 'DRA9I6095222264.L1bike, params= > null)

Sys.dbms_backup_restore.deviceDeallocate

END

Recover the archive log archive log file

SQL > DECLARE

Devtype varchar2 (256)

Done boolean

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= > 'DRA9I6095222264.arcwise params= > null)

Sys.dbms_backup_restore.deviceDeallocate

END

Mount database

SQL > alter database mount

Restore the database to a certain point in time

SQL > > recover database until time '2006-12-14 10 purl 0000'

Start the database

SQL > alter database open resetlogs

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report