You are on page 1of 1

Restoring a File to a new location

Backup and Recovery Tips

Restoring a File to a new location


Heres the scenario: File 3 has gone belly-up, because DISK2, on which it was housed, has had a head crash and is out of commission. The vendors are rushing you a replacement hard disk, but it wont be here until tomorrow but the database cannot be out of commission. So how do you recover data file 3 onto another hard disk, albeit a temporary one? Well, youre dealing with a complete recovery here, so the basics dont change: its still a question of restore (from backup) file 3 somewhere and apply all redo from available redo logs to bring it up to date. The only catch is the somewhere. Fortunately, the techniques for moving data files dont suddenly change just because you cant get the database open: its still a question of using the alter database rename file command. So, heres how you do it: 1. Restore File 3 from backups to another location (say, DISK3). 2. Get the database into the MOUNT state: STARTUP MOUNT 3. Issue the command: ALTER DATABASE RENAME FILE /DISK2/FILENAME.DBF TO /DISK3/FILENAME,DBF; 4. Issue the command: RECOVER DATAFILE 3; 5. Apply redo logs as usual for complete recoveries. 6. Open the database: ALTER DATABASE OPEN; When the new hard disk is installed, and you wish to move the file back to its proper home, perform the following steps: 1. Take the tablespace offline: ALTER TABLESPACE BLAH OFFLINE; 2. Use operating system commands to physically move the file to its new home 3. Tell the controlfile what youve done. Issue the command: ALTER DATABASE RENAME FILE OLD_FULLPATH/FILENAME TO /NEWPATH/FILENAME. 4. Bring the tablespace back on line: ALTER TABLESPACE BLAH ONLINE; Just make sure you always specify full path and filenames dont use environment variables the Control File seems to get upset from time to time if the path you specify is not literally and exactly what it expects. Id recommend querying the name column from the V$DATAFILE view before attempting any renaming operations, because that shows you exactly how the Control File stores the details. Finally, Ive shown you doing a complete recovery here, from the mount state. The principles dont change whatever type of recovery youre performing. The key is to issue the alter database command before attempting the recover xxx command.
Copyright Howard Rogers 2001 31/10/2001 Page 1 of 1

You might also like