# Restore Database

> Restore the PerformanceGuard database, and which SQL Server versions each PerformanceGuard version supports.

Source: https://docs.capaone.com/performanceguard/administration/more-setup/restore-database/  
Product: PerformanceGuard — a separate CapaSystems product; do not apply this page to any other.

PerformanceGuard supports the following relational database management systems:

1. **SQL Server 2012** (CPU license) from PerformanceGuard version 6.1.16
2. **SQL Server 2014** from PerformanceGuard version 6.5.100
3. **SQL Server 2016** from PerformanceGuard version 7.0
4. **SQL Server 2017** from PerformanceGuard version 7.4
5. **SQL Server 2019 RC1** have been tested with PerformanceGuard version 7.5 but no official release was available from Microsoft at the time of the release of PerformanceGuard 7.5

:::caution
The following information was written when PerformanceGuard supported SQL Server 2008 and 2008 R2. It describes how to restore a SQL Server 2008 R2 PerformanceGuard database that you have [Back Up Database](/performanceguard/administration/more-setup/back-up-database/). The procedure may vary slightly for other SQL Server versions, but you can still use the following as guidelines — also if you use newer SQL Server versions.
:::

:::caution
The following describes restoration of the PerformanceGuard backend server database, by default named *pguard*. If you want to restore a different database, substitute *pguard* with the name of the required database.
:::

1. Stop all PerformanceGuard services.
2. Open Microsoft SQL Server Management Studio and connect to the required database server.
3. In Microsoft SQL Server Management Studio's Object Explorer, locate the **pguard** database.
4. Right-click **pguard** and select **Tasks > Restore > Database**.
5. Microsoft SQL Server Management Studio will typically remember your backed-up version of the PerformanceGuard database. When that's the case, select **pguard** in the **From database** menu:  
   ![](/attachments/performanceguard/76bf7ace-d4c4-4e2d-9b35-6895db36833b.png)  
     
   If you can't select **pguard** this way, select **From device** and click the browse button next to the field. Then click the **Add** button and locate your pguard.bak backup file at the location that you noted down when you backed up the database. When ready, click **OK** twice to return to the **Restore Database** dialog.
6. Microsoft SQL Server Management Studio is now ready to restore your database and leave it ready to use by rolling back any uncommitted transactions. If you want to adjust the restore and recovery options, select the **Restore Database** dialog's **Options** page and make the changes that you require.  
     
   When ready, click **Next**.  
     
   The database will now be restored, and you'll be able to view the progress. When the restoration is finished, you'll see a confirmation message.
7. In Microsoft SQL Server Management Studio, right-click the **pguard** database and select **Properties** to verify that the restored database matches your expectations, especially with regards to file size limits.  
     
   When satisfied, click **OK**.
8. In Microsoft SQL Server Management Studio's toolbar, click **New Query**:  
   ![](/attachments/performanceguard/7e3870ee-8e5e-4dba-b4a4-97926c60b6b5.png)
9. Enter the following in the new query window (the white area in the middle of the Microsoft SQL Server Management Studio window). Remember to replace '*password*' with the actual required password for your database.

:::note[Important]
USE PGUARD  
  
IF NOT EXISTS(SELECT \* FROM master.dbo.syslogins where loginname = N'pguard')  
BEGIN  
        CREATE LOGIN pguard WITH PASSWORD = 'password', DEFAULT\_DATABASE = pguard  
        CREATE USER pguard FOR LOGIN pguard WITH DEFAULT\_SCHEMA = pguard  
        ALTER ROLE db\_owner ADD MEMBER pguard  
END  
ELSE  
BEGIN  
        ALTER LOGIN pguard WITH DEFAULT\_DATABASE = pguard  
        ALTER USER pguard WITH DEFAULT\_SCHEMA = pguard  
END
:::

   When ready, click the **Execute** button:  
   ![](/attachments/performanceguard/f50d41e6-f669-48df-a14a-e50e8f4db689.png)
10. Start all PerformanceGuard services again.
