Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2005
 How to: Restore a Database Backup (...

  Switch on low bandwidth view
Community Content
In this section
Statistics Annotations (0)
SQL Server 2005 Books Online (November 2008)
How to: Restore a Database Backup (SQL Server Management Studio)

This topic explains how to restore a full database backup.

ms177429.note(en-US,SQL.90).gifImportant:
Under the full or bulk-logged recovery model, before you can restore a database in SQL Server Management Studio, you must back up the active transaction log (known as the tail of the log). For more information, see How to: Back Up a Transaction Log (SQL Server Management Studio).

  1. After you connect to the appropriate instance of the Microsoft SQL Server Database Engine, in Object Explorer, click the server name to expand the server tree.

  2. Expand Databases. Depending on the database, either select a user database or expand System Databases, and then select a system database.

  3. Right-click the database, point to Tasks, and then click Restore.

  4. Click Database, which opens the Restore Database dialog box.

  5. On the General page, the name of the restoring database appears in the To database list box. To create a new database, enter its name in the list box.

  6. In the To a point in time text box, either retain the default (Most recent possible) or select a specific date and time by clicking the browse button, which opens the Point in Time Restore dialog box. For more information, see How to: Restore to a Point in Time (SQL Server Management Studio).

  7. To specify the source and location of the backup sets to restore, click one of the following options:

    • From database
      Enter a database name in the list box.
    • From device
      Click the browse button, which opens the Specify Backup dialog box. In the Backup media list box, select one of the listed device types. To select one or more devices for the Backup location list box, click Add.
      After you add the devices you want to the Backup location list box, click OK to return to the General page.
  8. In the Select the backup sets to restore grid, select the backups to restore. This grid displays the backups available for the specified location. By default, a recovery plan is suggested. To override the suggested recovery plan, you can change the selections in the grid. Any backups that depend on a deselected backup are deselected automatically.

    For information about the columns in the Select the backup sets to restore grid, see Restore Database (General Page).

  9. To view or select the advanced options, click Options in the Select a page pane.

  10. In the Restore options panel, you can choose any of the following options, if appropriate for your situation:

    • Overwrite the existing database
    • Preserve the replication settings
    • Prompt before restoring each backup
    • Restrict access to the restored database

    For more information about these options, see Restore Database (Options Page).

  11. Optionally, you can restore the database to a new location by specifying a new restore destination for each file in the Restore the database files as grid. For more information about this grid, see Restore Database (Options Page).

  12. The Recovery state panel determines the state of the database after the restore operation. The default behavior is:

    • Leave the database ready to use by rolling back the uncommitted transactions. Additional transaction logs cannot be restored. (RESTORE WITH RECOVERY)
      ms177429.note(en-US,SQL.90).gifNote:
      Choose this option only if you are restoring all of the necessary backups now.

    Alternatively, you can choose either of the following options:

    • Leave the database non-operational, and do not roll back the uncommitted transactions. Additional transaction logs can be restored. (RESTORE WITH NORECOVERY)
    • Leave the database in read-only mode. Undo uncommitted transactions, but save the undo actions in a standby file so that recovery effects can be reverted. (RESTORE WITH STANDBY)

    For descriptions of the options, see Restore Database (Options Page).

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Manually Change the "Restore As" filenames, or Management Studio may wipe out your data!      mcgmatt ... Thomas Lee   |   Edit   |   Show History

The restore feature only works correctly if you're rolling a database back to a previous version of itself. But most of the time, when I have to restore, it's restoring a live database back to a development database, to retrieve data that someone accidentally deleted. But the restore feature itself will lose a lot of data if you don't pay very close attention.

When restoring a backup from database X to database Y, you MUST go into Options and manually change the "Restore As" names for the database and log files, to tell it to overwrite the files for database Y. Otherwise, even though you told it to restore X to Y in the General section, it's actually going to overwrite X with an older version of X, destroying any newer data! And if you jump back to the General screen again, the Restore As paths are reset. This, even after two service packs!

Flag as ContentBug
manual change not needed      Charly Mortensen   |   Edit   |   Show History
In my experience if you select "restore to database Y" (test database) from a backup of database X (production database), it will overwrite the files of database Y, even though it says in the options menu that the "restore as" files are for database X. After proceeding with this, the Database X files had not been overwritten, only the files to Database Y.

I cannot make much sense of this, but i feel that i can safely assume that the selected "restore to" database is the only affected database during a restore from a file, no matter what it says under the options menu.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker