Database Restore

Understanding backup media type

Select a media type from the Backup media type drop-down list.

Note: The Tape option appears only if a tape drive is mounted on the computer, and the Backup Device option appears, only if at least one backup device exists.

Media TypeDialog BoxDescription
FileLocate Backup FileYou can select a local file from the tree or specify a remote file using its fully qualified universal naming convention (UNC) name. 
DeviceSelect Backup DeviceYou can select from a list of the logical backup devices defined on the server instance.
TapeSelect Backup TapeYou can select from a list of the tape drives that are physically connected to the computer running the instance of SQL Server.
URLSelect a Backup File LocationYou can select an existing SQL Server credential/Azure storage container, add a new Azure storage container with a shared access signature, or generate a shared access signature and SQL Server credential for an existing storage container.

Understanding Recovery State

The state of the database after the restore operation.

Database restore
  • RESTORE WITH RECOVERY is the default behavior which leaves the database ready for use by rolling back the uncommitted transactions. Additional transaction logs cannot be restored. Select this option if you are restoring all of the necessary backups now.
  • RESTORE WITH NORECOVERY which leaves the database non-operational, and does not roll back the uncommitted transactions. Additional transaction logs can be restored. The database cannot be used until it is recovered.
  • RESTORE WITH STANDBY which leaves the database in read-only mode. It undoes uncommitted transactions, but saves the undo actions in a standby file so that recovery effects can be reverted.

Restore a full database backup

STEP 1: In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.

STEP 2: Right-click Databases and select Restore Database.

restore database

STEP 3: On the General page, use the Source section to specify the source and location of the backup sets to restore. Select one of the following options:

  • Database – Select the database to restore from the drop-down list. The list contains only databases that have been backed up according to the msdb backup history.
  • Device – Click the browse () button to open the Select backup devices dialog box.

Remove – Removes one or more selected files, tapes, or logical backup devices.

Contents – Displays the media contents of a selected file, tape, or logical backup device. This button may not function if the media type is URL.

Backup media – Lists the selected media.

STEP 4: In the Destination section, the Database box is automatically populated with the name of the database to be restored. To change the name of the database, enter the new name in the Database box.

STEP 5: In the Restore to box, leave the default as To the last backup taken or click on Timeline to access the Backup Timeline dialog box to manually select a point in time to stop the recovery action

STEP 6: In 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. Backups that depend on the restoration of an earlier backup are automatically deselected when the earlier backup is deselected.

STEP 7: Optionally, click Files in the Select a page pane to access the Files dialog box. From here, 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.

STEP 8: To view or select the advanced options, on the Options page, in the Restore options panel, you can select any of the following options, if appropriate for your situation:

a. WITH options

  • Overwrite the existing database (WITH REPLACE)
  • Preserve the replication settings (WITH KEEP_REPLICATION)
  • Restrict access to the restored database (WITH RESTRICTED_USER)

b. Select an option for the Recovery state box. 

c. Take tail-log backup before restore. Not all restore scenarios require a tail-log backup. 

d. Restore operations may fail if there are active connections to the database. Check the Close existing connections option to ensure that all active connections between Management Studio and the database are closed. This check box sets the database to single user mode before performing the restore operations, and sets the database to multi-user mode when complete.

e. Select Prompt before restoring each backup if you wish to be prompted between each restore operation. This is not usually necessary unless the database is large and you wish to monitor the status of the restore operation.

STEP 9: Click OK.

Restore an earlier disk backup over an existing database

The following example restores an earlier disk backup of Sales and overwrites the existing Sales database.

STEP 1: In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
STEP 2: Right-click Databases and select Restore Database.
STEP 3: On the General page, select Device under the Source section.
STEP 4: Click the browse (…) button to open the Select backup devices dialog box. Click Add and navigate to your backup. Click OK after you have selected your disk backup file(s).
STEP 5: Click OK to return to the General page.
STEP 6: Click Options in the Select a page pane.
STEP 7: Under the Restore options section, check Overwrite the existing database (WITH REPLACE).
STEP 8: Under the Tail-log backup section, uncheck Take tail-log backup before restore.
STEP 9: Under the Server connections section, check Close existing connections to destination database.
STEP 10: Click OK.

Restore an earlier disk backup with a new database name where the original database still exists

The following example restores an earlier disk backup of Sales and creates a new database called SalesTest. The original database, Sales, still exists on the server.

STEP 1: In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
STEP 2: Right-click Databases and select Restore Database.
STEP 3: On the General page, select Device under the Source section.
STEP 4: Click the browse (…) button to open the Select backup devices dialog box. Click Add and navigate to your backup. Click OK after you have selected your disk backup file(s).
STEP 5: Click OK to return to the General page.
STEP 6: In the Destination section, the Database box is automatically populated with the name of the database to be restored. To change the name of the database, enter the new name in the Database box.
STEP 7: Click Options in the Select a page pane.
STEP 8: Under the Tail-log backup section, uncheck “Take tail-log backup before restore“.
STEP 9: Click OK.

Restore earlier disk backups to a point in time

The following example restores a database to its state as of 1:23:17 PM on May 30, 2016 and shows a restore operation that involves multiple log backups. The database does not currently exist on the server.

STEP 1: In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
STEP 2: Right-click Databases and select Restore Database.
STEP 3: On the General page, select Device under the Source section.
STEP 4: Click the browse (…) button to open the Select backup devices dialog box. Click Add and navigate to your full backup and all relevant transaction log backups. Click OK after you have selected your disk backup files.
STEP 5: Click OK to return to the General page.
STEP 6: In the Destination section, click on Timeline to access the Backup Timeline dialog box to manually select a point in time to stop the recovery action.
STEP 7: Select Specific date and time.
STEP 8: Change the Timeline interval to Hour in the drop down box (optional).
STEP 9: Move the slider to the desired time.
STEP 10: Click OK to return to the General page.
STEP 11: Click OK.

Restore Database to Point of Failure – Full Recovery

To restore to the point of failure. The is relevant only for databases that are using the full or bulk-logged recovery models.

To restore to the point of failure

  • Back up the tail of the log by running the following basic BACKUP statement:
BACKUP LOG <database_name> TO <backup_device>   
   WITH NORECOVERY, NO_TRUNCATE; 
  • Restore a full database backup by running the following basic RESTORE DATABASE statement:
RESTORE DATABASE <database_name> FROM <backup_device>   
   WITH NORECOVERY; 
  • Optionally, restore a differential database backup by running the following basic RESTORE DATABASE statement:
RESTORE DATABASE <database_name> FROM <backup_device>   
   WITH NORECOVERY; 
  • Apply each transaction log, including the tail-log backup you created in step 1, by specifying WITH NORECOVERY in the RESTORE LOG statement:
RESTORE LOG <database_name> FROM <backup_device>   
   WITH NORECOVERY; 
  • Recover the database by running the following RESTORE DATABASE statement:
RESTORE DATABASE <database_name>   
   WITH RECOVERY; 

 

Published by Abdul Samad

Having 17+ years of extensive experience in IT industry, enabled to enhance the team performance and maximize customer satisfaction by strategically managing calls and implementing process improvements. Demonstrated ability to solve problems, meets challenging goals, and expedites delivery. Skilled MSSQL administrator guide team during the crisis situation. Apply Creative thoughts process in re-designing the workflow system to eliminate duplication of effort and increase productivity.

Leave a Reply