Read time: 4 minutes
Summary: This content discusses various methods for SQL Server backup and restoration, emphasizing precautions before restoration. It provides detailed steps for restoring backups in SQL Server 2012 using Enterprise Manager, SQL Server Management Studio, and the new version of SSMS. The conclusion highlights the need for a third-party tool for recovering data from corrupted SQL backups.
SQL Server backups can be performed through various approaches, including employing T-SQL code, utilizing SQL Server Management Studio, or employing third-party software. The primary objective behind creating a database backup is to safeguard against potential issues such as corruption, data loss, system crashes, and to facilitate tasks such as database migration, creating duplicates of the database, and fulfilling other specific requirements.
Things to Be Taken Care of Before SQL Backup Restoration
Before you start the process of restoring database backup, you need to take care of a few things which are given under:
- Keep database backup ready.
- Keep the file location handy.
- You should have permission to access the file/directory.
- There should be no corruption of the backup file.
- The disk containing the backup file should be healthy.
- The version of the database should not be higher than the version of the SQL Server.
Methods to Restore Database Backup In SQL Server 2012
These methods can be used if you had taken care to backup your SQL Server database.
Method 1: Using Enterprise Manager in SQL Server 2012
Follow the steps given under to restore database backup in SQL Server 2012
- Start SQL Server 2012.
- Expand the database and select database right-click on it.
- Select Tasks > Restore > Database. The Restore dialog box will open.
- Select the database from the list under Source.
- Select the database from the list under Destination.
- Select the date of the database by clicking on Timeline. This will open a new dialog box.
- Select either the Last backup taken or Specific date and time. Press OK
- Select Files (on the left) and check to Relocate all files to folder.
- Select options (just below Files on the left).
- Choose from the following options: Restore Options, Tail-Log Backup, Server Connections, and Prompt as necessary. Then, click the OK button.
- The process of file restoration will commence, and upon its completion, a message will confirm the successful restoration of the database.
Method 2: Using SQL Server Management Studio
- Start SQL Server Management Studio (SSMS).
- Connect SSMS to that SQL Instance to which you will restore the backup.
- Under Object Explorer, right-click Databases.
- Select Restore Database. This will open a new dialog box.
- Under Source, select required Database (you can select it from the drop-down list)
- Under Destination, select Database to be restored.
- Under Restore, you have 2 options shown to restore the backup database, viz. Last backup taken or Select a specific date and time. Choose the desired option. Press OK
- Now Select ‘Files’ on the left pane. Check Relocate all files to folder to Restore database files by selecting the desired specified folders. You may rename the database files as well.
- Press Options on the left, below Files. Under Restore Options on the right, select any options as per your need.
- Select the desired option for Recovery State viz.:
- RESTORE WITH RECOVERY
The default action involves rolling back any uncommitted transactions, making the database immediately accessible. However, it does not reinstate any additional transaction logs. Choose this option when you need to promptly restore all essential backups.
- RESTORE WITH NONRECOVERY
This action does not reverse uncommitted transactions and leaves the database in a non-operational state. It involves the restoration of supplementary transaction logs, and the database can only return to usability following a recovery process.
- RESTORE WITH STANDBY
It switches the database to a read-only mode while rolling back any uncommitted transactions. Additionally, to facilitate recovery processes, it records the undo actions in a standby file.
NOTE: Do remember to check Close existing connections to close all active connections between SQL Server Management Studio and the database, or else it will render Restore Operations fail.
- Click OK if you wish to restore the database. Once the restore is successful, a message box will display it.
Method 3: Using new version of SQL Server Management Studio 19
The updated SQL Server Management Studio (version 19.0.1) features a distinct user interface from its predecessor. Consequently, understanding how to perform a complete database restoration is essential. Additionally, the new SSMU now offers compatibility with the most recent SQL Server versions, including 2022, 2019, and 2016. To accomplish this, follow the outlined procedure:
- In Object Explorer, connect with the correct SQL Server Database Engine and expand it to connect with the list of Databases.
- Right-click and choose ‘Restore Database.’
- The General wizard opens, and in the Source section, multiple options exist to select the Backup file for restoration. There are the following options –
From the drop-down list, pick the Database you want to restore. Only databases whose Backup was taken under the ‘msdb’ backup history are in the list.
There is a browser (…) button on which you can click to open the dialog box to choose the Backup file.
In the dialog box, choose the backup media type first, then Add the Backup files from various sources.
In the “Restore Database” section, when you choose the database, you have the option to either modify the database file’s name or restore it using its original name.
- You can either keep the Last Backup taken as the default option in the “Restore to” field, or you have the option to select “Timeline” to open the Backup Timeline dialogue box and manually choose a specific time point to pause the recovery process.
- Select the backups you wish to recover from the Backup Sets for Restoration grid. This grid displays the backups available for the specified location. An automatic recovery strategy is provided, but you have the flexibility to modify the selections within the grid to override the suggested recovery path. When you unselect a prior backup, any backups relying on its restoration are also automatically deselected.
- If relevant to your situation, you have the flexibility to select any of the following options available on the “Options” page within the Restore options panel, allowing you to review or make advanced selections:
6.1 WITH options
- Overwrite the existing database (WITH REPLACE)
- Preserve the replication settings (WITH KEEP_REPLICATION)
- Restrict access to the restored database (WITH RESTRICTED_USER)
6.2 Within the “Recovery State” section, select an option to control the database’s status following the restoration process.
- RESTORE WITH RECOVERY.
- RESTORE WITH NORECOVERY.
- RESTORE WITH STANDBY.
- Manage other options and click OK to start the restoration.
We trust that you have found this guide to be valuable when it comes to recovering a database backup in SQL Server 2012. It’s important to note that the methods mentioned above may not be effective if the backup is unavailable, corrupted, compromised, or misplaced. In such scenarios, you need a powerful and efficient third-party tool like Kernel SQL Backup Recovery, which can recover data from corrupted SQL backup files; it supports the recovery from all SQL Server versions, maintaining the integrity of data. In case you encounter any scenario of corruption of SQL backup, then also you need the help of the SQL Backup Recovery tool