Backup and Recovery Examples
| Article Index |
|---|
| 1. Recovering the Whole Database |
| 2. Recovering from Loss of All Control Files without backup |
| 3. Restoring and Recovering Datafiles and Tablespaces |
- How to Schedule backups using enterprise manager?
- How to relocate archive-log backups to different disk location?
- How to recover whole database without backup if all Control Files are lost?
- How to restore and recover from loss of datafiles and tablespaces?
1. Recovering the Whole Database
You have a current control file and SPFILE but all datafiles are damaged or lost. You must restore and recover the whole database.
The database has one read-only tablespace, history, which must be restored from backup but which does not need media recovery.
The procedures will restore the whole database to their original locations.
Pre-Requests
- A Closed or open valid DB backup needed for media recovery.
- You must have the complete set of archived logs.
- The current control file is available.
- The database is mounted and should not be open.
Background
- With a complete set of online and archived redo logs, RMAN can re-create a datafile for which there is no backup, by creating an empty datafile and then re-applying all changes since the file was created.
- After recovery of a whole database, when the database is opened, any missing temporary tablespaces recorded in the control file are re-created with their previous creation size, AUTOEXTEND and MAXSIZE attributes.
- Only temporary tablespaces that are missing are re-created. If a tempfile is still present at the location recorded in the RMAN repository but has an invalid header, then RMAN does not re-create the file.
Create Scenario
Solution-1
1 |
RMAN> STARTUP MOUNT |
2. Recovering from Loss of All Control Files without backup
You can recover the database in case if have last all control files.
Data used by Recovery Manager will be lost If you were using the control file as the RMAN repository.
Assuming you are doing this on Windows, the files will be locked. This is the directory snap where your datafile, controlfile and redolog files are residing.

The control files will be renamed and then a startup will be attempted.
1 |
-- Clean shutdown to release the locks on the files |
Now we can treat this situation as having to create control files. If the control files are missing, then the database cannot be mounted, Any attempt to mount will fail because of the missing files.
1 |
SQL> SELECT STATUS FROM v$instance; |
No problem, we’ll use the command to create a control file from trace.
1 |
SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS 'C:\TRACE.TXT'; |
As you can see, not being mounted is a show stopper for this approach. What is required is to manually create a statement. We need the names of all of the datafiles and redolog files in the database for this step (see the first diagram).
We have to match the redo log filename to the redo log group. That can be tricky because with N groups, there will be N! ways of making those assignments.
Using what Windows is reporting as the file sizes (in KB), we can construct a CREATE CONTROLFILE statement as shown:
1 |
CREATE CONTROLFILE |
If get the error look like this you need to adjust redo log or datafile sizes
1 |
ORA-01503: CREATE CONTROLFILE failed |
Now that the control file(s) has been created, what is the state of the database? Verify that your files have been created, and then select the status from V$INSTANCE and see MOUNTED. If the database is mounted, can it be opened? The answer is yes.
1 |
SQL> ALTER DATABASE MOUNT; |
You can notice there is no temp file associated with database we need to add temp file.
1 |
ALTER TABLESPACE "TEMP" |
Your DB is now opened and full functional.
3. Restoring and Recovering Datafiles and Tablespaces
The database is open, and some but not all of the datafiles are damaged. You want to restore and recover the damaged tablespace, while leaving the database open so that the rest of the database remains available. You discover that the damaged datafiles are from the tablespaces users.
Background
Pre-requests
- Make sure the database is mounted or open
- A Closed or open DB backup and archivelog is required
Create Scenario
1 |
SQL> connect sys/srdc |
Solutions-1 [Default Location]
1 |
#Connect to the target database |
Solutions-2 [New Location]
Assume that the old datafiles were stored in directory /olddisk and the new ones will be stored in /newdisk.
1 |
RUN { |
Solutions-3 [System Tablespace is missing]
if a non-system tablespace is missing or corrupted while database is open, recovery can be performed while DB remains open.
if the system tablespace is missing or corrupted the DB can not be started up so a complete closed based recovery must be performed
Last Updated (Tuesday, 24 November 2009 11:31)



