How to recover data (undelete / undo) in Salesforce?
If the data is accidentally deleted in Salesforce or is mass updated incorrectly (during data import with update or upsert operation or through an Apex program), then what are the different options that you can have to recover your data or undo the changes?
If the data is deleted, then you can restore (undelete) the data from the recycle bin (unless, of course, you have hard deleted it or emptied the recycle bin). Once the records are deleted, they are stored in the recycle bin for 15 days.
You can run a SOQL query with "IsDeleted = TRUE ALL ROWS" and see if you are able to view the deleted data and recover it from here.
If you have taken any CSV backup (either manually or through Salesforce's data export option), then you can restore the records from the CSV backup using Data Loader.
However, if any of the above is not an option, then the last resort that you can turn to is to contact Salesforce.com to recover your data. And here is what you should know before you take this route:
This is NOT FREE and NOT CHEAP—there is a minimum charge of USD 10K.
You can specify the date/time up to which the data should be recovered.
Data can be recovered up to 3 months back from the current date for a production instance.
Data can be recovered up to 1 month back from the current date for a sandbox instance.
This process may take up to 15 business days.
Salesforce will give you a set of CSV files, which you will then need to import into your Salesforce org using an import tool. So this service does not mean you will have your data back directly in your Salesforce org.
Any relationship (master-detail, lookup) will need to be re-established using Salesforce record IDs or external IDs.
While recycle bin and IsDeleted = TRUE are options for "undeleting" the data, they won't help if you need to "undo" changes. The only option to "undo" changes is to have a CSV backup and either update records from that CSV backup or delete current records and reinsert from CSV.
As an Administrator, if you are not backing up your data on a periodic basis, then this is a good time to rethink it.
Here are the options that you can choose from:
The simplest option is to turn on the Salesforce Data Export service. With this option you will have at least a weekly or monthly backup depending on your Salesforce edition. In fact, there is no reason why this should not be turned on for any Salesforce production org.
If weekly backup is not acceptable, then you can schedule a daily export using Apex Data Loader. This will involve some time and effort on your part to set this up. But once set up, the whole process can be automated to run on a daily basis. With this option you can either back up the data on a local PC or even think about using cloud services like Amazon Web Services (AWS).
For more sophisticated backup and recovery options, you can explore AppExchange for a suitable third-party tool.
Whichever method you choose, do not ignore backing up your Salesforce data on a regular basis. This can be a lifesaver for you and your organization.
If you are still not convinced, check out this knowledge article by Salesforce that clearly states "While Salesforce.com backs up all data and can restore data, it's important to back up and be able to restore your own salesforce.com data."