Monday, September 19, 2016

Why and how to backup salesforce data

Why backup salesforce data? Isn't this done by salesforce automatically?
Yes, Salesforce does perform real time replication to disk for each of their data centers, and near-real time data replication between production data center and disaster recovery center. However, there are quite a few scenarios why you might want to have your own backup. Scenarios such as:

  1. Recover from data corruption
  2. Rollback for data migration activity
  3. Archive data to reduce data volume or to adhere to data retention policies
  4. Replicate data to warehouse

How to backup data?
Depending upon your backup requirements (Full, Incremental, Partial) you can choose to use salesforce native features such as Data Export or Data Loader or you can build your own custom solution. In case you decide to build your own solution there are 4 API's that you can choose from.

  • REST API
  • BULK API
  • SOAP API
  • Metadata API
How to choose the right API for the job?
Before we jump into identifying the right API for the job, lets first understand some of the limitation around these API's, knowing about these limitation will help us in deciding which API to use:


API
Governor Limit
Additional consideration
Objects Not supported
REST or SOAP
Unlimited Edition: 15,000 + (number of licenses X calls per license type) calls per 24-hour period.
The calculation of the API request limit based on user licenses is designed to allow sufficient capacity for your org based on your number of users. If you need a higher limit and you don’t want to purchase extra user licenses or upgrade to Performance Edition, you can purchase additional API calls

Bulk API
Submit up to 10,000 batches every 24-hour.
Batch older than 7 days are removed from queue.
Each batch cannot be more than 10Mb in size
Batch can contain a max or 10,000 records

Each batch is divided into chunk of 200records.
Each chunk can take up to 5 mins of processing and total time allowed for complete batch is 10 mins.
If batch takes more than 10 mins its put into queue for later processing, if batch takes more than 10 mins for 10 attempts its marked as failed.
CaseStatus
ContractStatus
KnowledgeArticle
KnowledgeArticleVersion
KnowledgeArticleVersionHistory
KnowledgeArticleViewStat
KnowledgeArticleVoteStat
LeadStatus
OpportunityStage
PartnerRole
RecentlyViewed
SolutionStatus
TaskPriority
UserRecordAccess

Now that we have a high level understanding on the limitation on API's lets consider some common use cases:

Use Case 1: Need to back up object containing a large volume of records (more than 2 million):
Recommendation: Bulk API - Bulk API are generally faster then SOAP and Rest API

Use Case 2: Back up data but also preserve limits regarding number of API calls per 24 hours:
Recommendation: Bulk API - Bulk API do not consume API Calls but consume Bulk API calls. Useful for orgs with less number of user licenses.

Use Case 3: Back up data but preserve bulk API limits:
Recommendation: REST or SOAP API - REST or SOAP API do not consume Bulk API limits however they have there own limitation, Useful for orgs where Bulk API are utilized for other activities.

Use Case 4Backup an object that contains a lot of XML-like information
Recommendation: REST or SOAP API While this is not directly caused by the Salesforce SOAP API, we have seen some XML parsers encountering difficulties when processing the HTTP response (mix of XML-based protocol and XML data)

Use Case 5 Backup an object that is not yet supported by the Bulk API 
Recommendation: REST or SOAP API - Well the objects are not supported in Bulk API

Use Case 6: You need to backup metadata
Recommendation: Metadata API - Well there are not much options, may be you can think of use Tooling API however Tooling API is meant for developing interative application or developer tools. For more details see when to use tooling api


1 comment:

  1. I acknowledge the author for his brilliant work for making this exceptionally useful and informative content to guide us.
    salesforce onilne forms

    ReplyDelete