Sunday, January 4, 2009

Basics of Backups

 A backup is a copy of data.


 A backup is a safeguard against unexpected data loss
.
 Backup of the database can be taken in three ways

1) User managed backup
2) RMAN backup and
3) Logical backup

User Managed Backup:

 This method uses operating system commands like cp, tar for backup and SQL*plus for recovery.

 This method can be used to take the cold backup and hot backup Depending on the database instance, whether it is running archive mode or non archive mode.

 In this method ,you need to take the copy of complete datafiles ,controlfiles


RMAN backup:

 RMAN is a utility automatically installed with the database that can back up any Oracle8 or later database.
 By using RMAN, we can backup only the used blocks in the datafies also it supports incremental backup.
 The major advantage of using RMAN is, it stores the metadata of the backups in the controlfile, whereas in the user managed backups we need to manually note down the information about the backups
 It also identifies the bock corruption and writes to v$database_corruption
 In this method, we can’t backup the initiazation parameter and password files



Logical Backups:

 Logical backups are nothing but exporting the schema objects to a flatfile or binaryfile by using exp command.





Backup terminology:


Whole Database Backup:


Whole database backup includes the backup of all datafiles and controlfiles.

These backups can be performed when the database is open or closed

Whole database backup that is taken when the database is closed by using shut immediate,normal,transactional is called a consistent backup.In this backup, all the database file headers are consistent with the controlfile so when you restore , there is no recovery is needed.

When the database is operated in the archivelog mode, only a consistent backup is valid


Inconsistent backupd:

When the database is open ,the datafile headers are not consistent with the controlfile. Also when you shut down the database with abort option, this inconsistency occurs.

Backups of the database in such state is called as inconsistent backup .

These backups need require recovery to bring the database into a consistent backup..

You can take the backup of the database ,while it is open .this is called hotbackup or open backup. For this , database must be in the archive log mode




To perform the user managed consistent backup,

1) Shut down the database (not with abort option)
2) Copy all the required files to the backup location
3) Open the database

Disadvantes:

1) you can recover the dAtabase until the last backup.



Open database backup:

1) you should obtain the information about the files of the database by querying the v$datafile, v$controlfile,v$logfile, dba_data_files
2) we can perform the online backup at tablespace level or datafile level.
3) Place the tablespaces in the begin backup mode by using
Alter tablespace tablespace_name begin backup
And then copy all the datafiles corresponding to that tablespace
4) after the copy set the tablespace in the normal mode by
alter tablespace tsname end backup

5d) repeat the steps to all the tablespaces and finally archive the current redolog file by issuing the


Alter system archive log current;




We can obtain the datafiles status information by using v$backup and v$datafie_header views

1) for V$backup view, there is a cumn named status , if the status of a datafile is active, then it is in the backup mode
2) for v$datafile_header view, there is fuzzy coloumn is there, if the valus of the fuzzy coloumn is yes , then the corresponding datafile is in the backup mode



For 9i,

We cant set the entire database in the backup mode but we can bring back to the normal state by issuing

Alter dAtabase end backup;


In 10g,
We can place the entire database in the backup mode by issuing the
Alter dAtabase begin backup

For read only tablespaces

1) when you change a tablespace in to a readonly tablespace, a checkpoint occurs on the all corresponding datafiles and the dAtaheaders are frozen to the current scn.
2) Dbwr wont write the information in to the corresponding Datafiles, so you no need to take the backup again. One valid backup is enough



Logging and nologging


When you use nologging option, there is no redo generated for that tablespace , so you cant recover the corresponding tabespace ,when you take the online backup


Controlfile backup;

There are two ways to take the controlfile backup

1) binary image of the controlfile by using
\ alter database backup controlfile to ‘controlfile name’

2) by creating a script to generate the controlfile

alter database backup contolfile to trace

after this statement, a trace file contains the script to generate the controlfile is stored in the userd_dumpd_dest


It is best practice to take the controlfile backup

Whenever you change the structure of the database
When you changing to nologging to archivelog



DBVERIFY command



Dbverify is the command line utility is used to verify the backup datafiles are valid before it is restored


It identifies the block level corruption and the executable is dbv

No comments:

Post a Comment