How to migrate ADManager Plus from one version of Microsoft SQL Server to another
Last updated on:In this article
Objective
When you upgrade Microsoft SQL Server or move to a new SQL Server instance, the ADManager Plus database needs to move with it so that ADManager Plus can continue to use its existing data. You can move the database in Microsoft SQL Server Management Studio (SSMS) by detaching and attaching it, or by backing it up and restoring it.
Prerequisites
- Your ADManager Plus build supports the destination SQL Server version. ADManager Plus supports up to SQL Server 2022.
- The user account that runs ADManager Plus has access to the destination SQL Server instance, with either the sysadmin role, or the db_datareader, db_datawriter, and db_ddladmin roles and Execute permission on the database.
- If the destination SQL Server is on a different computer, SQL Native Client, Command Line Utilities, and ODBC Driver are installed on the ADManager Plus server. On the SQL Server computer, SQL Server Browser is running, TCP/IP is enabled, and the TCP and UDP ports are open in the firewall.
- The Database Master Key of the ADManager Plus database is backed up on the source SQL Server. To back up the key:
- Get the master key password. Open the customer-config.xml file in the \conf folder of the ADManager Plus installation folder and copy the value of the masterkey.password property. The value is encrypted. To get the decrypted value, contact ADManager Plus support.
- In Microsoft SQL Server Management Studio on the source server, run the following queries. Replace YourDatabaseName with the name of the ADManager Plus database, and YourMasterKeyPassword with the decrypted password. The folder in the file path (C:\Backup in this example) must already exist.
USE YourDatabaseName;
GO
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'YourMasterKeyPassword';
GO
BACKUP MASTER KEY
TO FILE = 'C:\Backup\YourDatabaseMasterKey.key'
ENCRYPTION BY PASSWORD = 'YourMasterKeyPassword';
GO - Copy the generated .key file securely to the same folder on the destination server.
Steps to follow
You can use either of the following built-in Microsoft SQL Server methods to migrate the ADManager Plus data from one version of Microsoft SQL Server to another.
To migrate from PostgreSQL to Microsoft SQL Server, or to an Always On or cloud SQL setup, see Database migration.
Method 1: Using detach and attach
Use this method when the destination SQL Server version is the same as or newer than the source version. Detaching removes the database from the source server.
- Stop ADManager Plus and back up the ADManager Plus database.
- Log in to Microsoft SQL Server Management Studio.
- Right-click the database that you want to move, click Tasks, and then click Detach.
- In the Detach Database window, select Drop Connections and Update Statistics, and click OK.
- Navigate to the storage path of the database, for example, C:\Program Files\Microsoft SQL Server\MSSQL<version>.<instance name>\MSSQL\DATA.
- Copy the .mdf and .LDF files (for example, admp.mdf and admp_log.LDF) and save them in the desired location.
- Log in to Microsoft SQL Server Management Studio on the destination server, right-click Databases, and click Attach.
- In the Attach Databases window, click Add.
- Browse to the location where you saved the .mdf file, select it, and click OK.
Note:
When you select the .mdf file, the .LDF file is selected automatically.
- Navigate to the ADManager Plus installation folder, go to the \conf folder, and open the database_params.conf file.
- Change the SQL Server location and database name so that ADManager Plus points to the new database.
Method 2: Using backup and restore
This method also needs a destination SQL Server version that is the same as or newer than the source. Unlike detaching, it leaves the original database on the source server, so you can go back to it if needed.
- Stop ADManager Plus. Then, in SSMS on the source server, right-click the ADManager Plus database and click Tasks > Back Up to create a backup file (.bak).
- Copy the .bak file to the destination server.
- Log in to Microsoft SQL Server Management Studio on the destination server.
- Right-click Databases and click Restore Database.
- In the Restore Database window, under Source, select Device and click the browse (...) button.
- In the Select backup devices window, make sure Backup media type is set to File, and click Add.
- In the Locate Backup File window, browse to the .bak file, select it, and click OK.
- In the Select backup devices window, click OK.
- Under Destination, make sure Database shows the ADManager Plus database name, and click OK.
- Go to the \conf folder in the ADManager Plus installation folder and open the database_params.conf file.
- In the file, replace the SQL Server location and database name with those of the destination server and the restored database.
Restore the Database Master Key
Whichever method you used, restore the Database Master Key on the destination SQL Server before you start ADManager Plus.
- In Microsoft SQL Server Management Studio on the destination server, run the following queries. Replace YourDatabaseName with the name of the ADManager Plus database, and YourMasterKeyPassword with the decrypted password.
USE YourDatabaseName;
GO
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'YourMasterKeyPassword';
GO
RESTORE MASTER KEY
FROM FILE = 'C:\Backup\YourDatabaseMasterKey.key'
DECRYPTION BY PASSWORD = 'YourMasterKeyPassword'
ENCRYPTION BY PASSWORD = 'YourMasterKeyPassword';
GO
ALTER MASTER KEY ADD ENCRYPTION BY SERVICE MASTER KEY;
GO - To verify the restore, run the following queries.
SELECT *
FROM sys.symmetric_keys
WHERE name = '##MS_DatabaseMasterKey##';
GO
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'YourMasterKeyPassword';
GO - Start ADManager Plus.