How to Restore a Database
This article describes how to restore a Sql Server database from a backup.
Suppose we have a database containing information about the planets in our solar system: Planets.
We've backed up the database into a BAK file named Planets.bak.
Get Logical File Names
Display the logical file names:
RESTORE FILELISTONLY
FROM DISK = 'E:\Backups\Planets.bak'
Here's a portion of the result set:
|
LogicalName
|
PhysicalName
|
Type
|
|
Planets
|
e:\MSSQL\Planets.mdf
|
D
|
|
Planets_log
|
e:\MSSQL\Planets.ldf
|
L
|
Create Empty Database
Create an empty database and name it the same as the logical file name
shown in the result set for the MDF.
- Select Databases in Microsoft Sql Server Management Studio
- Right-click and select New Database...
- Sql Studio displays the New Database dialog.
- Enter the database name into the "Database name" field.
For our example, we enter "Planets" for the database name.
- Click OK.
Restore the database
Restore the database:
RESTORE DATABASE [Planets]
FROM DISK = 'E:\Backups\Planets.bak'
WITH REPLACE
Users & Logins
You may need to create users and logins that were not backed up in the backup set.
Test
Examine the restored database and check that it contains the tables, stored procedures, etc. you expect
to find in the database.
Run an application that accesses the database and validate whether the database contains
the expected data.
|