triz-docs/docs/database-operations/sql-server-backup-restore/restoring.md
2026-04-29 11:32:42 +01:00

94 lines
3.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
sidebar_position: 3
title: "Restoring a Database"
---
# Restoring a Database
---
**WARNING:** Restoring a database **replaces its current contents**. Always confirm you are targeting the correct server and database before proceeding. Close any active connections to the target database beforehand.
---
## Restore from a Full Backup
1. In **Object Explorer**, right-click the **Databases** node (not a specific database) and select **Restore Database…**
![SSMS Restore Menu](img/16.png)
2. The **Restore Database** window opens on the **General** page. Under **Source**, select **Device**, then click the … (Browse) button.
![Restore Source Device](img/17.png)
3. In the **Select backup devices** dialog, click **Add**.
![Add Backup Device](img/18.png)
4. Navigate to your `.bak` file, select it, and click **OK**. Then click **OK** again to close the dialog.
![Select BAK File](img/19.png)
5. The backup details will populate in the **Backup sets to restore** grid. Verify that the correct backup is checked.
6. Under **Destination**, confirm the database name in the **Database** field. You can type a new name here to restore as a different database.
![Verify Restore Sets](img/20.png)
7. Go to the **Options** page (left-hand panel). Check **Close existing connections to the destination database** to avoid connection conflicts during restore.
8. Click **OK** to begin.
![Restore Options](img/21.png)
9. A confirmation message will appear on success.
![Restore Success](img/22.png)
---
## Restore from a Full + Differential Backup
1. Follow steps 14 above, but when adding backup devices, add **both** the full backup file and the differential backup file.
![Add Multiple Backup Devices](img/23.png)
2. SSMS will automatically detect the backup types and display them in the correct order in the **Backup sets to restore** grid.
3. Make sure **both** the full and differential entries are checked.
![Multiple Restore Sets](img/24.png)
4. Go to **Options**, check **Close existing connections to the destination database**.
5. Click **OK** to restore.
---
## Point-in-Time Recovery (Transaction Logs)
1. Follow steps 14 above, adding the full backup file **and all transaction log** (`.trn`) files in the **Select backup devices** dialog.
![Add Log Files](img/25.png)
2. SSMS will list all backup sets in the correct sequence in the grid. Verify all needed entries are checked.
3. To restore to a specific point in time, click the **Timeline…** button at the top of the **General** page. In the **Backup Timeline** dialog, drag the slider or type a specific date and time, then click **OK**.
![Restore Timeline](img/26.png)
4. Go to **Options**, check **Close existing connections to the destination database**.
5. Click **OK** to run the restore.
---
## Restoring to a Different Server or Name
To restore a backup onto a different server, or under a different database name:
1. Connect SSMS to the **target server** (not the original one).
2. Follow the restore steps in the section above.
3. At step 6, change the **Database** name field to your desired new name.
![Rename Database](img/27.png)
4. Go to the **Files** page (left-hand panel). You will see the original file paths listed. Check **Relocate all files to folder** and specify the data and log folders on the target server.
![Relocate Files](img/28.png)
5. Click **OK** to restore.