Backup data to another Salesforce org

Backup data to another Salesforce org

In this post, I will cover basic process that anyone can consider while backup data. This is specifically for backup process not for migration. Migration is a wider term that can have lot of data transformation steps in between for which various ETL tools come into picture.

In this, We will backup one org's data into another Salesforce org using external Ids. To accomplish this, I have setup a basic plan:

Explore & choose environment for backup

Developer Edition cannot be used for this purpose as it has very limited space i.e. something around 5.0MB. We need to definitely go for any of sandboxes.

Very ideal way is to use partial copy sandbox, create a template , backup your data & leave it. This is the simplest way to take a backup & requires no effort/resources but many organisations don't want to waste their partial copy sandbox for this.

Next would be to determine amount of data that needs to backup up. If data size is less than 200MB, We can go for normal developer sandbox. If it is more than 200MB, Developer pro sandbox is good as it has 1GB data limit.

More info can be found here.

Deploy data model to target Salesforce

This step is only required if you are not using any sandbox for backup as sandboxes already have every configuration same as production. Just make sure you disable all processes like triggers/workflows/validation rules etc.

If using another production org, Deploy data model from origin to target org. Make sure you don't migrate any triggers/workflows/validation rules etc. to target as these can interfere & can make this process a nightmare.

NOTE: If you are trying to backup data of a managed package. You need to contact your package provider and ask for a new version that allows you to disable these processes. They can simply do by adding a custom setting that run triggers only it is active & subscribers can disable it after installation. Other processes like workflows/validation rules can be disabled directly

Add an External Id field to every object

Add new field with attributes(external Id & unique) to every data model object with name yourname_External_Id__c. This field is to store existing origin record ids in target system.

Arrange data model in hierarchy

For big organizations, A complex data model can exist for which we need to align them in hierachy as this will make our import steps very easy. For example, We need to import all Users first, then Accounts, all related Contacts & then all related Cases.

Export & transform CSVs.

This step is to extract everything related to data model. This ideally should be done with Data Export as it is very easy and requires no effort. Download all data is in your local machine.

Very Important: Open every CSV & add an extra column with header yourname_External_Id__c and copy Id column's data into this. This is to ensure that we have all origin org ids related to records and store them in external id fields created in above step.

Import data

Import can be done with any tool as per wish. There are many tools available in market. I have used Workbench & Dataloader specifically in this case as they are very simple to use.

Important: Before importing, There is a thing that needs to be consider. If you want to import your audit fields as well (CreatedDate, CreatedBy, LastModifiedDate, LastModifiedBy etc.), then you need to enable a permission for your migration user. To know more details, You can go to Specify values in Audit fields article.

Now to import, You just need to take care of your mappings i.e. Mapping of your fields.

Another Important point to note that while mappings, We have to map all master-detail/lookup relationships to map through external Id.

Lets take an example of Account & Contact.
Suppose Accounts have been imported correctly and it has new id & previous id is stored in yourname_External_Id__c field which is an external id too. Now While importing Contacts, map AccountId to this external id field instead of Id and salesforce will automatically search for Account with this external Id in system and link the contact. This way we are actually linking contacts with existing previous Account Ids.

I have attached screenshots of workbench & dataloader mappings to help this understand:

Workbench using external Id Datloader using external Id

Sample sdl file for dataloader showing mapping:

#Mapping values
#Tue May 17 12:52:39 IST 2016
Account\ ID=Account:lk_main__External_Id__c
Last\ Name=LastName

Hope this will help people & give some start up idea before making a plan :)

Lakshay Katney Avatar

Lakshay Katney

Saleforce developer by profession but I like to work with various technologies.I blog about Force.com, Hybrid Apps, PhoneGap, AngularJS, BackboneJS, JavaScript in general. I am Angular & NodeJS fan.

Read More
Share this page
Latest 15 Posts

100%