(Solution) Move Protected Server Between Two DPM Servers – (ID: 31162)

6 min read

In this article, I will share with you how to move an existing protected server with DPM to another DPM server and solve the following issue:

One or more of the selected data sources are already configured for protection on the primary DPM server. When you switch back protection, the replicas of these data sources will be protected from the primary DPM server. (ID: 31162).

Introduction

System Center 2019 Data Protection Manager (SCDPM) is the latest release by Microsoft and with it comes a lot of improvements and new features. You can read more about what’s new in System Center 2019 Data Protection Manager here.

SCDPM is well recognized in the industry for the protection of Microsoft workloads and environments. With SCDPM 2019, you can protect application workloads such as Hyper-V VMs, Microsoft SQL Server, SharePoint Server, Microsoft Exchange, VMware VMs, Windows Server, and Windows clients to:

  • Disk (D2D) giving the high Recovery Time Objectives (RTOs) for tier 1 workloads, short-term protection on-premises.
  • Tape (D2D2T) for long-term online and off-site protection (Physical/Virtual Tape).
  • Azure (D2D2C) for long-term online and off-site protection.

For more information on how to install System Center 2019 Data Protection Manager on Windows Server 2019, please check the following step-by-step guide.

I have recently come across a scenario where my primary DPM server failed due to hardware failure. In the same environment, I have another (standalone) DPM server sitting idle where I can use it to re-protect my production servers.

Since the primary DPM server is not available anymore, I went to the protected servers and re-point the DPM agent to the new DPM server using the (SetDPMServer.exe -dpmServerName DPMServerName) command.

When I am creating a new protection group and selected the data source, I received the following warning:

One or more of the selected data sources are already configured for protection on the primary DPM server. When you switch back protection, the replicas of these data sources will be protected from the primary DPM server. (ID: 31162).

(Solution) Move Protected Server Between Two DPM Servers - (ID: 31162) 1

The data source cannot be protected because it is still blocked by the failed DPM server.

Cause of the issue

After some digging, I have found that the problem was the DPM agent on the protected server communicated to the new DPM server that it was already protected by another DPM server and wrote it in the DPMDB on the secondary DPM server.

The entries of the protected data source on the primary DPM server could not directly protect on the secondary DPM server.

Please note that I am not using DPM Chaining (Primary/Secondary) in this environment. Additionally, moving protected servers between DPM servers that are under secondary protection isn’t supported. Please check the official documentation from Microsoft here to understand the different scenarios.

Resolution

To fix this issue, you need to take the following steps:

  1. First, you need to take a backup of the DPM database. This is a very important step before you proceed with the remaining steps.
  2. Update the DPM agent.
  3. Run the SQL query below to delete the entries of the protected server for the primary DPM server on the secondary (standalone) DPM server.

Please note that this workaround is NOT supported by Microsoft. Use the instructions below at your own risk, except and only when you are specifically instructed by Microsoft technical support specialist to do this.

SQL Query

You need to change the following two items in the script below:

  • old-dpm.domain.com – Replace with FQDN of the original primary DPM server name in your environment (which no longer exist).
  • protected-srv1.domain.com – Replace with FQDN of protected server or cluster name you want to clean up.

The SQL query that you want to run is the following:

-- Script to cleanup 'secondary protection history' from a DPM server
 
USE DPMDB -- Verify this is correct if using remote SQL server instance.
DECLARE @PrimaryDPMName NVARCHAR(400)
DECLARE @PSName NVARCHAR(400)
DECLARE @HyperVCLUSTERName NVARCHAR(400)
SET @HyperVCLUSTERName = 'default'
 
-- Provide the actual values below before running. 
-- @PrimaryDPMName is the name of the DPM server which was protecting this PS primarily.
-- @PSName is the name of the production server for which the history has to be cleaned up. 
--  In the case of a clustered resource, you need to run this shell script a minimum of three times and change the 
-- @PSname variable to include:
     -- Node1.domain.com
     -- Node2.domain.com
     -- Cluster-resource.cluster.domain.com
     
-- @HyperVCLUSTERName is OPTIONAL and is ONLY used to cleanup a Hyper-V Cluster resources, un-comment that line and run the script after all other -- cleanup work was done.
-- BE SURE TO INCLUDE THE '% %' around the hyper-V cluster name
 
SET @PrimaryDPMName = 'old-dpm.domain.com'  --replace with FQDN of original primary dpm server name
SET @PSName = 'protected-srv1.domain.com'  -- replace with FQDN of protected server name you want to cleanup
--SET @HyperVCLUSTERName = '%optional%' -- OPTIONAL - replace with '%FQDN_CLUSTER_NAME%' of the Hyer-V cluster only.
 
-- Step 1:
-- Check whether all the datasources from the PS of interest are in stop protected state on not.
 
-- Get the Secondary DPM Server ID
DECLARE @SecondaryDPMServerId Guid
DECLARE @error INT
 
SET @error = 0
 
SELECT @SecondaryDPMServerId = ServerId
FROM tbl_AM_Server
WHERE ServerId = DPMServerId
AND IsDPM = 1
AND MarkedForDeletion = 0
 
SELECT @error = dbo.udf_DPS_CheckRowCount(1)
IF (@error <> 0)
BEGIN
    PRINT 'Could not get the secondary DPM ServerId. Aborting.'
  GOTO _Exit
END
 
-- Get the Primary DPM Server ID
DECLARE @PrimaryDPMServerId Guid
SET @error = 0
 
SELECT @PrimaryDPMServerId = ServerId
FROM tbl_AM_Server
WHERE DPMServerId = @SecondaryDPMServerId
AND ServerId <> @SecondaryDPMServerId
AND ServerName = @PrimaryDPMName
AND IsDPM = 1
AND MarkedForDeletion = 0
 
SELECT @error = dbo.udf_DPS_CheckRowCount(1)
IF (@error <> 0)
BEGIN
    PRINT 'Could not get the primary DPM ServerId for server ' + @PrimaryDPMName + '. Exiting...'
GOTO _Exit
END
    
-- Locate the PS of interest
DECLARE @ServerId Guid
SET @error = 0
 
SELECT @ServerId = ServerId 
FROM tbl_AM_Server
WHERE ServerName = @PSName
AND MarkedForDeletion = 0
 
SELECT @error = dbo.udf_DPS_CheckRowCount(1)
IF (@error <> 0)
BEGIN
    PRINT 'Could not find the production server '+ @PSName + '. Aborting.'
GOTO _Exit
END
    
-- Get all the datasources protected from this server
DECLARE @ProtectedDSCount INT 
SET @ProtectedDSCount = 0
 
SELECT @ProtectedDSCount = COUNT(DS.DataSourceId)
FROM tbl_IM_DataSource DS
WHERE DS.ProtectedGroupId IS NOT NULL
AND DS.ServerId = @ServerId
 
IF (@ProtectedDSCount <> 0)
BEGIN
    SELECT 'Following datasources are actively protected.' +
           ' Execute this script after stopping their protection with retain data.'
    AS ErrorMessage
 
    SELECT DS.DataSourceName AS Datasource,  
        AM.ServerName AS OnServer, 
        PG.FriendlyName AS ProtectedInPG
    FROM tbl_IM_DataSource DS
    JOIN tbl_AM_Server AM
        ON AM.ServerId = DS.ServerId  
    JOIN tbl_IM_ProtectedGroup PG
        ON PG.ProtectedGroupId = DS.ProtectedGroupId
    WHERE DS.ProtectedGroupId IS NOT NULL
    AND DS.ServerId = @ServerId
        
  GOTO _Exit
END
 
-- Step 2:
-- Cleanup the tables
 
-- Delete the DatasourceVolume entries corresponding to the PS-datasource and
-- PrimaryDPM-replicavolume
SET @error = 0
 
DELETE tbl_IM_DatasourceVolume
FROM tbl_IM_DatasourceVolume DsVol
JOIN tbl_IM_Volume Vol
    ON DsVol.VolumeId = Vol.VolumeId
JOIN tbl_IM_DPMDatasourceReplicaProperties DSProp
    ON DsVol.DataSourceId = DSProp.DataSourceId
JOIN tbl_IM_DataSource DS
    ON DS.DataSourceId = DSProp.DataSourceId
WHERE DSProp.ServerId = @PrimaryDPMServerId
AND Vol.ServerId = @PrimaryDPMServerId
AND DS.ServerId = @ServerId
 
SELECT @error = @@ERROR 
IF (@error > 0) 
BEGIN
    PRINT 'Could not clean up the DatasourceVolume entries.' 
    PRINT 'Errorcode: ' + CAST(@error AS varchar(10))
  GOTO _Exit  
END
 
-- Delete the entries in tbl_IM_DPMDatasourceReplicaProperties
SET @error = 0
 
DELETE tbl_IM_DPMDatasourceReplicaProperties
FROM tbl_IM_DataSource DS
JOIN tbl_IM_DPMDatasourceReplicaProperties DSProp
    ON DS.DataSourceId = DSProp.DataSourceId
WHERE DSProp.ServerId = @PrimaryDPMServerId
AND DS.ServerId = @ServerId
 
SELECT @error = @@ERROR 
IF (@error > 0) 
BEGIN
    PRINT 'Could not clean up the DPMDatasourceReplicaProperties table. ' 
    PRINT 'Errorcode:' + CAST(@error AS varchar(10))
END
 
-- ADDED  2-28-13 to cleanup Hyper-V cluster resources
 
-- Delete the entries in tbl_IM_DPMDatasourceReplicaProperties for HyperV clustered resources associated with Hyper-V cluster
-- Skip this section if  @HyperVCLUSTERName = 'default'
IF @HyperVCLUSTERName = 'default'
goto _exit
 
-- check to see if  @HyperVCLUSTERName entered matches known hyper-v clusters
 
DECLARE @ClusterCount INT 
SET @ClusterCount = 0
 
SELECT @ClusterCount = COUNT(cd.Clustername)
FROM dbo.tbl_AM_ClusterDetail cd
WHERE Clustername like @HyperVCLUSTERName
and Isdag = 0
IF (@ClusterCount = 0)
begin
PRINT 'Could not get the HyperV Cluster name like ' + @HyperVCLUSTERName + '. Aborting.'
goto _exit
end 
 
-- Now start clean up of Hyper-v data sources associated with @HyperVCLUSTERName 
 
SET @error = 0
 
delete tbl_IM_DPMDatasourceReplicaProperties
where DataSourceId in (select Datasourceid from dbo.tbl_IM_DataSource ds
join dbo.tbl_AM_Server AM on ds.ServerId = am.ServerId
where am.ServerName like @HyperVCLUSTERName)
 
SELECT @error = @@ERROR 
IF (@error > 0) 
BEGIN
    PRINT 'Could not clean up the DPMDatasourceReplicaProperties table. ' 
    PRINT 'Errorcode:' + CAST(@error AS varchar(10))
END
 
_Exit:  
 
PRINT 'Exiting...'
 
-- SCRIPT ENDS HERE

Finally, try to re-protect the protected server to the new DPM server and you should be able to select the data source that you want to protect again.

Hope this helps!

Learn more

Do you want to learn more about System Center Data Protection Manager and how to create a hybrid-cloud backup solution? Make sure to check my recently published book: Microsoft System Center Data Protection Manager Cookbook.

With this book (over 450 pages) on your side, you will master the world of backup with System Center Data Protection Manager and Microsoft Azure Backup Server deployment and management by learning tips, tricks, and best practices, especially when it comes to advanced-level tasks.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Related Posts

About Charbel Nemnom 579 Articles
Charbel Nemnom is a Cloud Architect, Swiss Certified ICT Security Expert, Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT), totally fan of the latest's IT platform solutions, accomplished hands-on technical professional with over 17 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems. Excellent communicator is adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design, business continuity, and cloud security.

Be the first to comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.