locked
Migrating Production Database to Development Environment RRS feed

  • Question

  • Hello,

    Once again I resort to the forums for some needed help :)

    I have 1 CRM Dynamics 4 production environment and 1 Dynamics 4 Development environment. They are separate each installed on a different server and with different databases.

    Through the time the differences in customizations , views, etc have increased between the 2 installations to the point I can´t guarantee anymore that when I export from one side to the other the apps will be the same (not mentioning I get several errors doing that).

    So my goal Is to make sure I have in the DEV server exactly the same database along with all the customizations,views, basically with a copy of the Production DB.

    So I made a backup of the Production DB (only the _MSCRM, not the Config one) and restored it to the DEV SQL Environment.

    I then went to the DEV Environment config DB and changed the pointers in the "Organization" table to this new DB. It didn't work , I can't even start CRM which leads me to think I'm doing this the wrong way.

    I tried another way by again restoring the Production DB to the DEV Server and then importing the organization (using Multitenancy) but I also can´t complete that operation. First it gives a warning that the DB versions are different. Then it gives me an error related to some user in the AD (which should be working fine since it is on the Production Environment).

    So I guess my question would be what's the best way to do this?

    If any additional info is needed please let me know and I will provide it ASAP.

    Thanks for your time.

    Friday, January 11, 2013 10:35 AM

Answers

  • I ended up importing the Organization with just the 2 admins created and left the others out.

    Case solved.

    • Marked as answer by Agenteusa Thursday, February 21, 2013 10:06 AM
    Thursday, February 21, 2013 10:06 AM

All replies

  • You have the right approach in restoring the production DB and then importing through Deployment Manager.

    Your dev server needs to be on the same rollup as the production one (or higher, but same is better so any dev and testing you do is more valid). This should avoid the error you are seeing because the MSCRM_config database is at a different UR than the prod_mscrm database.

    The AD user errow may be spurious because the first part of the operation fails, but if it persists, come back with the actual wording of the error, or detail from the Deployment Manager log file (in the roaming profile folder of the installing user on the deployment server. NB that if you close DM and restart it, you get a new log, which is much easier to troubleshoot - if you keep trying different things, keep closing it and starting again.)


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    • Proposed as answer by nrodriEditor Tuesday, January 15, 2013 12:26 PM
    Friday, January 11, 2013 2:21 PM
  • If DEV is on a different domain than PROD, then you will have to use the "Map User" step in the Import Wizard and map them to different AD users.

    I agree with Adam; you'll want the CRM servers to be on the same update rollup.

    Tuesday, January 15, 2013 1:07 PM
  • Sorry if I haven´t replied soon, I had lots of implementations to deal with lately so I couldn't get back to you sooner. :S

    Anyway I applied the rollup to the DEV server and now the warning is gone when importing.

    I still have the same error though when importing and it's always with the same user...I have attached the last part of the log changing some private names with USERNAME and ORGNAME.

    16:38:08|Verbose| Old account {0}| DEVELOP\USERNAME
    16:38:08|Verbose| Adding new account {0}| DEVELOP\USERNAME
    16:38:08|Verbose| Found dn {0}| CN=XXX,OU=Direcção de Negócios,OU=Direccao Executiva,OU=ORGNAME,DC=esript,DC=local
    16:38:08|Verbose| Attempting to add user using distinguished name. DN = {0}, Account Name = {1}| CN=USERNAME,OU=Direcção de Negócios,OU=Direccao Executiva,OU=ORGNAME,DC=esript,DC=local, DEVELOP\USERNAME
    16:38:10|  Error| Failed to add user using the DistinguishedName = CN=USERNAME,OU=Direcção de Negócios,OU=Direccao Executiva,OU=ORGNAME,DC=esript,DC=local, Account Name = DEVELOP\USERNAME
    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
       --- End of inner exception stack trace ---
       at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
       at Microsoft.Crm.BusinessEntities.SecurityUtils.AddPrincipalToGroup(SecurityIdentifier sid, DirectoryEntry groupEntry)
       at Microsoft.Crm.BusinessEntities.SecurityUtils.AddPrincipalToGroup(Guid principalId, SecurityIdentifier sid, Guid groupId)
       at Microsoft.Crm.Tools.Admin.DBImportHelper.AddExistingUserToOUGroup(User user, String adOUGroupName)
    16:38:10|  Error| An error occurred when populating Microsoft CRM user groups. Ensure that CRM user accounts are accessible from the current domain and run the wizard again.System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
       --- End of inner exception stack trace ---
       at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, Object[] args)
       at Microsoft.Crm.BusinessEntities.SecurityUtils.AddPrincipalToGroup(SecurityIdentifier sid, DirectoryEntry groupEntry)
       at Microsoft.Crm.BusinessEntities.SecurityUtils.AddPrincipalToGroup(Guid principalId, SecurityIdentifier sid, Guid groupId)
       at Microsoft.Crm.Tools.Admin.DBImportHelper.AddExistingUserToOUGroup(User user, String adOUGroupName)
       at Microsoft.Crm.Tools.Admin.DBImportHelper.AddExistingUserToOUGroups(User user, String userGroupName, String reportingGroupName)
    16:38:30|  Error| Import Organization (Name=ORGNAMEDEV, Id=b155b3c4-f95f-e211-9781-00155dc85a04) failed with Exception:
    System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed.
       at System.Data.SqlClient.SqlConnection.GetOpenConnection(String method)
       at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
       at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command)
       at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
       at Microsoft.Crm.CrmDbConnection.SetTransactionIsolationLevel(IsolationLevel il)
       at Microsoft.Crm.CrmDbConnection.Dispose(Boolean disposing)
       at Microsoft.Crm.SqlExecutionContext.Dispose(Boolean disposing)
       at Microsoft.Crm.SqlExecutionContext.Dispose()
       at Microsoft.Crm.Tools.Admin.ImportOrganizationInstaller.Import(Guid organizationId, String organizationUniqueName, String organizationFriendlyName, String sqlServerName, String databaseName, Uri reportServerUrl, String privilegedUserGroupName, String sqlAccessGroupName, String userGroupName, String reportingGroupName, String privilegedReportingGroupName, ICollection`1 users, MultipleTenancy multipleTenancy)
    16:38:30|Warning| Attempting to cancel a long running process: ProgressWizard. This might leave the data in an invalid state and the application might not function correctly.

    Can you guys figure out anything from this log?

    Chris,

    Do you mean mapping users manually 1 by 1?

    Thanks again for the help.


    • Edited by Agenteusa Wednesday, January 16, 2013 4:53 PM
    Wednesday, January 16, 2013 4:51 PM
  • When importing an Org and creating / mapping users, the users will get added to the ReportingGroup group in AD in the OU you specified when doing the original installation. It looks (at a quick read) like it is this group update which is failing.

    Make sure the user you are logging in as to perform the import has the rights to modify these groups - this may also depend on the logged on user being mapped to an existing user record in the imported database where that user is an administrator for the old CRM (ie has system admin role).

    Also take a look at this previous thread and the notes about users in the old CRM database with no domain specified:

    http://social.microsoft.com/Forums/en-IE/crmdeployment/thread/a7290a11-44ef-46ea-89d7-b13e39ae68ad


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right


    • Edited by Adam Vero Wednesday, January 16, 2013 5:09 PM added link
    Wednesday, January 16, 2013 5:05 PM
  • I'm logged on as a SysAdmin so I have access to everything.

    I have to admit I'm a bit confused about your second statement :

    "this may also depend on the logged on user being mapped to an existing user record in the imported database where that user is an administrator for the old CRM (ie has system admin role)"

    You mean if the user that's throwing the error is an admin? No it isn't, it updates several users ok then always throws an error at that specific one.

    You think it could have something to do with the AD itself? i mean the user is registered in the PROD DB and it's working fine but I'm starting to wonder at this point.

    One more one, I have already an organization registered on the DEV environment that consists of a DB and the CONFIG_MSCRM which is not the same as the PROD environment. Then I'm restoring the PROD DB (only, not the CONFIG one that is in the PROD environment) and running the deployment manager to import the ORganization.

    Is this the right approach or do I need the CONFIG DB from the PROD environment as well?

    Wednesday, January 16, 2013 5:20 PM
  • OK - I did not see that some users were working and one failing. Probably not an issue mapping the admin user.

    You do not want the Prod config_mscrm database, only org_mscrm, that is correct.

    Have a look at the other thread I linked - it may be possible you have a user in the Prod CRM who has an invalid record which does not specify a domain. You may need to look in systemuserbase table to check this, or may be able to see in the User record through the GUI since you know the user causing the problem.


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    Wednesday, January 16, 2013 5:24 PM
  • Nope, the user doesn't have any records attached to him and furthermore it's inactive.

    What field exactly should I look for in the Systemuserbase table?

    Wednesday, January 16, 2013 5:41 PM
  • Use something like:

    SELECT FullName, DomainName from [Prod_MSCRM].[dbo].[SystemUser]

    to get the name and domain name from the systemuser filtered view, assuming your Prod CRM database is Prod_MSCRM. You can include a "WHERE" to get just the one user if you want to.


    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    Blog: Getting IT Right

    Wednesday, January 16, 2013 5:50 PM
  • Yes the user has a domain name DEVELOP/USERNAME like all users.

    Wednesday, January 16, 2013 6:03 PM
  • Well, I tried the import with just 2 users, myself and the admin. It worked fine and strangely enough most of the users are already in the DB anyways even though I only mapped 2 of them.

    Seems its working but I 'm still not sure how and why it worked and why I have all the users even though I didn't map them...

    Thursday, January 17, 2013 12:19 PM
  • The error message in the log file were telling you exactly what the issue was:

    Failed to add user using the DistinguishedName = CN=USERNAME,OU=Direcção de Negócios,OU=Direccao Executiva,OU=ORGNAME,DC=esript,DC=local, Account Name = DEVELOP\USERNAME
    Microsoft.Crm.Tools.Admin.DBImportHelper.AddExistingUserToOUGroup

    That you were able to successfully import the Organisation by bypassing the mapping of the offending User suggests the same; that you and/or whichever AD principal was mapping the AD Users into the new CRM Deployment had insufficient privileges on the AD User to be able to add AD Group(s) to that AD User.

    With respect to the system working without mapping ALL users; have you tested that the users can actually log in?  Because without mapping them they should not be able to, as their AD User Accounts will not have been mapped (in the MSCRM_CONFIG Deployment database) to the new Deployment.

    You can manually map Users after the import, but you will have to map each of them to a temporary AD User then map them back again.


    --pogo (pat) @ pogo69.wordpress.com

    Friday, January 18, 2013 3:39 AM
  • It's strange that I would not have permissions to add users to groups in the AD has I am a power user with admin rights. It's possible though, it's a field that I really dont have much knowledge in :S

    The MSCRM_CONFIG had already mappings for most of the users as the DEV application already had the users, so I think if they try they should be able to login.

    Even if they can't it's not really an issue since I only needed them there for data purposes as only 2 people are going to use this DEV application. It's just for development purposes and internal testing.

    Friday, January 18, 2013 10:21 AM
  • I ended up importing the Organization with just the 2 admins created and left the others out.

    Case solved.

    • Marked as answer by Agenteusa Thursday, February 21, 2013 10:06 AM
    Thursday, February 21, 2013 10:06 AM