CRM 2011: Moving organisations from one environment to another en masse
In our development environment we have quite a few CRM servers and every now and then we have a need to build new ones and migrate all of the organisations from one server to another.
I thought I would share the way that I do it in case you were faced with a similar challenge and needed a quick way of getting it done.
In this post I will be covering the method in which I move many CRM organisations from one environment to the other. The environments are pretty much exactly the same as one another so there is no migrating from Windows auth to IFD or anything like that and both servers are in the same domain.
Unfortunately I can't cover how to get powershell working with your CRM deployment in this post as it can be quite complicated depending on the way your server is configured. So this post assumes that you have a brand new CRM environment where everything is working and ready to receive CRM Organisations.
Please note that my CRM Servers are running WMF5 and CRM 2011 and my scripts are built to run in that environment.
Export the CRM org details from the source CRM server.
- Login to your Source CRM server as a deployment admin and open an elevated PowerShell window.
- run the following command:
Get-CrmOrganization | Export-Clixml -Path C:\CRMOrgs.xml
- Copy the CRMOrgs.xml file to the destination CRM server. We will need that for later.
Backup all of the CRM organisation databases.
I find that the quickest way to take all the needed backups is to just use a SQL maintenance plan.
If you know how to make a maintenance plan and run it skip ahead to the next section called Restore the SQL Databases, we are just backing up the databases here.
- Open SQL Management Studio and connect to your server instance.
- Expand Maintenance Plans
- Right click --> New Maintenance Plan
- Give it a name and click OK.
- From the Toolbox menu on the left, drag and drop the Backup Database Task to the Maintenance plan window.
- Right Click the Backup Task --> Edit.
- Make sure the backup Type is "Full" and that Compress Backup is ticked.
(if you can't see the Compress Backup option go and make sure that it is turned on in the SQL server options. it is under Database Settings. Trust me, this will make the backups run much faster and the restores run faster.)
- Click the drop down for Databases, select the "These Databases" Radio button and select all of the org_MSCRM databases. Don't take the MSCRM_Config or any of the non CRM databases.
- Under Destination, specify a network location that both SQL service users have access to read and write to and click OK.
- Save the maintenance plan and hit the refresh button in the Object explorer.
- Right click your maintenance plan and click Execute.
- This might take a while so go get a coffee or something.
Create a Script to Restore all of the SQL Databases
- Download this script and Open it in PowerShell ISE to edit it.
- Change the value of
$BackupFilesLocationto point to the folder where you stored your backups.
- Run the Script.
- Go to the $BackupFilesLocation and look for a file called FileList.csv and open it with Excel.
- At the very bottom of the PS1 file, you will see an excel formula, copy it into C2 and change the File Paths that are specified after
MOVE 'mscrm' TOand
MOVE 'mscrm_log' TOso that the SQL MDF and LDF files are restored to the correct location on your new SQL server.
- Check that the File names and database names in the formula make sense and fill down that formula for each DB listed in the CSV.
The values in Column C combined are essentially the script that we will use to restore the databases and we will need them in the next step.
Restore the SQL Databases to the new SQL server.
- Open SQL Management Studio and connect to your new SQL server.
- Click on New Query in the ribbon menu.
- Copy all of the values from Column C in our spreadsheet into the New Query window.
- Execute the query. All of your SQL Databases will eventually restore.
This could take some time.
Import the CRM Organisations
Login to your new CRM server as a deployment administrator and open an elevated PowerShell ISE window.
Download this script and edit it in ISE. You will need to update the following script parameters with the values that suit your environment:
After you run this, you can keep on running Line 9 over and over just to see how many imports are left to do. But that is pretty much it! After the jobs are completed, your CRM will have all of the CRM organisations in it and you can start letting users access it. If you are running CRM in IFD mode you will still have to update the DNS records but I won't go through that here.
If you have a huge amount of DNS records to modify though, I will give you a hint on how you can automate it. The FederationMetadata.xml file that the CRM generates has every CNAME you will need to create for that deployment. Have fun!