Microsoft Word - Restoring a File to a new

Page 1

Restoring a File to a new location

Backup and Recovery Tips

Restoring a File to a new location Here’s 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 won’t 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, you’re dealing with a complete recovery here, so the basics don’t change: it’s 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 don’t suddenly change just because you can’t get the database open: it’s still a question of using the “alter database rename file” command. So, here’s 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 you’ve 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… don’t 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. I’d 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, I’ve shown you doing a complete recovery here, from the mount state. The principles don’t change whatever type of recovery you’re 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


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.