Migrating data is a bit like marmite, you either love it or hate it. You need to have an understanding of how data is organised by tables, rows and columns in a relational database, plus have a very methodical and tenacious nature which you don’t mind being put to the test. So, if you’ve already switched off from this blog, data migration may not be your thing.
For anyone still reading who may have been tasked with migrating Files from one Salesforce org to another, this is for you. I have performed a fair amount of data migration in the past, but nothing could have prepared me for migrating Files as that’s a whole different ball game. I found various papers explaining how to do parts of the migration, but nothing that explained the end-to-end process, so my aim here is to do exactly that and save you from the trials and tribulations I experienced.
There are 3 main stages for org-to-org File migration:
Step 1
Use the Data Export function in Salesforce to export the Files. Check the box ‘Include Salesforce Files and Salesforce CRM Content document version’. You don’t need to export the actual data.
This creates one or more zip files. When you extract them, look out for the following:
ContentVersion folder (contains the Files so there may be more than one folder)
ContentVersion.csv (contains the ID of each File)
ContentDocumentLink.csv (contains the IDs to relate Files to records)
Step 2
Unzip the ContentVersion folder(s) into a single ContentVersion folder on your local drive.
Step 3
This is where you prepare to import the Files into the target org. Recreate the ContentVersion.csv file from Step 1 with:
Title |
(Required) - File name |
Description |
(Optional) |
PathOnClient |
(Required) - The path name of where you have stored the Files in Step 2 (e.g. C:\Files\ContentVersionAll) |
Version Data |
(Required) - The PathOnClient, plus the file Name (e.g. C:\Files\ContentVersionAll\0680P000006N82BQAS - this is the File Name found in the ContentVersion folder) |
|
I would also recommend creating an External ID field on the target ContentVersion object to hold the original Salesforce ID, as this will assist with relating records correctly further down the process. |
Step 4
Use the new ContentVersion.csv file to insert the Files into the target org ContentVersion object.
Step 5
Now that the Files have been imported to the target org, each File will have been allocated a new ContentDocumentID. This will now be used to link the File to the related records.
Here’s the tricky bit. You now need reconstruct the ContentDocumentLink.csv file, using the IDs from the target org, which could be different to the IDs in the source org (if you have performed a data migration prior to this). This should be made simpler by using the External ID from Step 3 to match the records. Choose whichever method you are comfortable querying data with, e.g. lookups in Excel, MySQL queries or even MS Access. There is no ‘right’ application or method to use.
The new ContentDocumentLink.csv file (which you will then import into your target org), needs to be constructed as follows:
ContentDocumentID |
(Required) - From the import success file in Step 4, or the export in Step 5 |
LinkedEntityID |
(Required) - The record ID of the related record in your target org |
ShareType |
(Required) - The permission granted to user. For valid values, see the 'Description' details for the field in the ContentDocumentLink | SOAP API Developer Guide |
Visibility |
(Optional) - Specifies whether this file is available to all users, internal users, or shared user. Refer to the field's 'Description' details in the guide link above |
Renaming and Converting Chatter Content after exporting:
Now that you know how to migrate Files, you have probably gathered that moving anything other than Salesforce records can be a little complex. Another type of data you might want to migrate is Chatter Content. All those helpful internal interactions need to be backed up, or even migrated if you are moving to another system. If you have ever exported Chatter Files, Content and Attachments using the Weekly/Monthly Export Service before, you will probably know that everything comes out in an indecipherable fashion, and cannot be opened. Luckily, this article explains exactly what you need to do to convert your Chatter Content back to its original form, and make it usable outside of Salesforce.
Good luck!
Take a look at our Salesforce tutorial videos.