0% found this document useful (0 votes)
84 views4 pages

Backup and Recovery

The document describes different types of Oracle database backups and recoveries. It discusses cold backups, hot backups, complete recovery, recovery in noarchivelog mode, recovery in archivelog mode, open database recovery when initially open or closed, recovery of datafile without backup, and incomplete recovery using time-based or cancel-based methods. Procedures are provided for each type using SQL commands.

Uploaded by

shaikali1980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views4 pages

Backup and Recovery

The document describes different types of Oracle database backups and recoveries. It discusses cold backups, hot backups, complete recovery, recovery in noarchivelog mode, recovery in archivelog mode, open database recovery when initially open or closed, recovery of datafile without backup, and incomplete recovery using time-based or cancel-based methods. Procedures are provided for each type using SQL commands.

Uploaded by

shaikali1980
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Backup:

Cold Backup:

1. SQL> Shutdown immediate


2. OS copy command
3. SQL> Startup

Hot Backup:

1. SQL> Select name from v$tablespace;


2. SQL> Select d.name from v$datafile d,v$tablespace t where t.ts#=d.ts# and
t.name=<tablespace name>;
3. Repeat step 2 for all tablespace and collect the list of datafiles for all tablespace
4. SQL> Alter tablespace <tablespace name> begin backup;
5. OS copy of all datafiles in that tablespace
6. SQL> Alter tablespace <tablespace name> end backup;
7. Repeat step 4, 5 and 6 for all tablespaces in the database.

Recovery:

Complete Recovery:

Recovery in NoArchivelog mode:

1. SQL> Shutdown immediate


2. OS copy command
3. SQL> Recover database until cancel using backup controlfile;
4. SQL> Cancel
5. SQL> Alter database open resetlogs;

Recovery in Archivelog mode:

Basic information gathering (has to be done for all recovery in archive mode):

1. Determine which datafile needs recovery. Query the v$recover_file table as follows:
SQL> select d.name from v$datafile d, v$recover_file r where d.file#=r.file#;
2. Find the list of all archived redolog files for the database. Query the v$archived_log
table as follows:
SQL> select name from v$archived_log;
3. Find the list of all archived files required for recovery. Query the v$recovery_log table
as follows:
SQL> select archive_name from v$recovery_log;
Complete Recovery of closed database:

Used for:
1. System tablespace datafiles
2. Rollback segment datafiles
3. Whole database

Steps:
1. SQL> Shutdown immediate;
2. OS copy command
3. SQL> Startup mount
4. SQL> Recover database
5. SQL> Alter database open;

Open database recovery when database is initially open:

Used when:
1. Database is currently open
2. Database will remain open during recovery
3. Media failure doesn’t affect system tablespace

Steps:
1. Check the status of the datafile as follows:
SQL> Select d.file#, d.name, d.status from v$datafile d,v$datafile_header h where
d.file#=h.file#;
Incase oracle has not taken the file offline, take datafile offline using following
command:
SQL> Alter database datafile <filename> offline;
2. OS copy of that datafile from backup;
3. SQL> Recover datafile <filename> (OR)
SQL> Recover tablespace <name>
4. SQL> Alter database datafile <name> online (OR)
SQL> Alter tablespace <name> online;

Open database recovery when database is initially closed:

Used when:
1. Media or hardware failure has bought system down
2. Database is operational 24*7 and downtime has to be minimum.
3. Damaged files do not belong to system tablespace
4. Database is now closed but will be made open during recovery.

Steps:
1. SQL> Startup mount
2. SQL> Alter database datafile <name> offline;
3. SQL> Alter database open;
4. OS copy of datafile from backup (restore to new location.)
5. SQL> Alter database rename file <name> to <newname>;
6. Check the tablespace name for datafile using the following command:
SQL> select file_id f#, file_name, tablespace_name, status from dba_data_files;
7. SQL> Recover datafile <name> (OR)
SQL> Recover tablespace <name>
8. SQL> Alter database datafile <name> online; (OR)
SQL> Alter tablespace <name> online;

Recovery of datafile without backup:

Used when:
1. Media or user failure has resulted in loss of datafile that was never backed up
2. All archive logs exist since the file was created
3. Affected files do not belong to system or undo segment tablespace
4. Cannot be used when control file has been recreated.

Steps:
1. SQL> Alter tablespace <name> offline immediate;
2. SQL> Alter database create datafile <name> as <new name>;
3. SQL> Recover tablespace <name>;
4. SQL> Alter tablespace <name> online;

Incomplete Recovery:

Time based recovery:

Used When:
1. Table dropped at 12:00 and current time is 12:15 but the table has to be recovered
2. Transaction between 12 and 12:15 will be lost

Steps:
1. SQL> Shutdown
2. OS copy command – restore all datafiles
3. SQL> Startup mount
4. SQL> Recover database until time <time>;
5. SQL> Alter database open resetlogs;
6. SQL> Archive log list
7. Check if the table is restored.
8. Complete cold backup
9. SQL> Startup
Cancel based Recovery:

Used when:
1. Time is 12 and employee table dropped at 11:45. Table has to be recovered.
2. Log file exists on same disk.

Steps:
1. SQL> Shutdown
2. OS copy – restore all datafiles
3. SQL> Startup mount
4. SQL> Recover database until cancel;
5. SQL> Alter database open resetlogs;
6. Take cold backup
7. Startup database again

You might also like