# Move Database

> Move the PerformanceGuard database to another server, and which SQL Server versions are supported.

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

PerformanceGuard supports the following relational database management systems:

- **SQL Server 2012** (CPU license) from PerformanceGuard version 6.1.16
- **SQL Server 2014** from PerformanceGuard version 6.5.100
- **SQL Server 2016** from PerformanceGuard version 7.0
- **SQL Server 2017** from PerformanceGuard version 7.4
- **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 move a SQL Server 2008 R2 PerformanceGuard database to another SQL Server 2008 R2 instance. 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.
:::

# **Back Up Existing Database**

Follow the procedure in [Back Up Database](/performanceguard/administration/more-setup/back-up-database/) and then return to this topic.

# **Restore Database on New SQL Server Instance**

:::caution
The following describes how to restore the PerformanceGuard backend server database (that is the **pguard** database). You should use a similar process if you want to restore the frontend server database (that is the **pguardfe** database), but in that case you should substitute **pguard** with **pguardfe**.
:::

1. Stop all PerformanceGuard services.
2. Open Microsoft SQL Server Management Studio and connect to the required database server as *sa* user (that is with system administrator rights).
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.
   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. Select the **Restore Database** dialog's **Options** page. For every database file in the list, change the path to the required new location.  
   ![](/attachments/performanceguard/8aa8681e-df42-4f66-bbc0-70279162d7e0.png)

:::tip
Maximize the window to better view the list of database files.
:::

:::caution
If you use SQL Server 2012 and 2014, the files have their own page in the *Restore Database* dialog.
:::
7. Microsoft SQL Server Management Studio is now ready to restore your database at the new location, and leave it ready to use by rolling back any uncommitted transactions. If you want to further adjust any restore and recovery options, do this while you work on the **Options** page.  
     
   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.
8. 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**.
9. In Microsoft SQL Server Management Studio's toolbar, click **New Query**.
10. Enter the following in the new query 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.

11. Start all PerformanceGuard services again.

# **Change Database Connection Information**

When the database has been moved, you must change the configuration of the PerformanceGuard services so that it reflects the new location of the database.

:::note[Important]
**Remember to Stop All Services**

Before editing the settings. Remember to stop all services. Otherwise all settings will be overwritten with current running Values.
:::

## **If You Moved the Backend Server Database**

Change the configuration in setting.ini:

1. **Open** *\[PerformanceGuard installation folder\]\settings.ini*

   1. *Change the following entries:*

      1. BE\_DB\_HOST= "New SQL server"
      2. BE\_JDBC\_CONNECTSTRING=jdbc:sqlserver://"New SQL server";databaseName=pguard;
2. **Save** Settings file

## **If You Moved the Frontend Server Database**

Change the configuration in setting.ini:

1. **Open** *\[PerformanceGuard installation folder\]\settings.ini*

   1. *Change the following entries:*

      1. FE\_DB\_HOST= "New SQL server"
      2. FE\_JDBC\_CONNECTSTRING=jdbc:sqlserver://"New SQL server";databaseName=pguardfe;
2. **Save** Settings file

After Saving Settings.ini with the new configuration. Start all services, and check logs for connections success
