Exporting data

In the previous section, we saw that we can export data from Salesforce in the following ways:

  • Reports: By exporting resulting datasets in CSV (or Excel) format
  • Data Loader: By using a SOQL query to get a CSV file that contains the results
You can use other tools or even build your own using the SOAP and REST APIs in order to run SOQL and SOSL queries. You can even use Chrome extensions to do this job on the fly (a full list of Chrome extensions, by Salesforce MVP Jitendra Zaa, can be found at https://www.jitendrazaa.com/blog/salesforce/top-google-chrome-extensions-for-salesforce/).

Salesforce CRM comes with a backup tool that you can leverage to export data from your organization in CSV format, back it up, and so on. This feature is called Data Export and can be found by going to Setup | Data | Data Export.

The tool allows you to do a one-time data export, though it can be scheduled on a weekly or monthly basis, depending on your Salesforce edition (only Enterprise, Performance, and Unlimited deliver the weekly option).

Click on the Export Now button to get to the following page:

From here, do the following:

  1. Choose file encoding.
  2. Check the Include images, documents, and attachments and Include Salesforce Files and Salesforce CRM Content document versions checkboxes, which will create bigger files and increase the export time, respectively.
  3. Check the Replace carriage returns with spaces box if you want to replace carriage returns/line breaks with a single space (this is useful for certain kinds of integration formats).
  4. Select the kind of data you want to export. By selecting Include all data, you are, as the option suggests, including every Salesforce object.
The kind of objects that are exported depends on the time you create the export job, so if you are creating weekly/monthly export jobs and you create a new object after their creation, remember to update the export job by selecting Include all data.

When you hit the Start Export button a job is enqueued and, as usual, Salesforce sends a notification email when the export job has completed:

Scheduled Data Export has a similar configuration, except for the scheduled time frame:

Because jobs are run according to the platform's load, sometimes, export results won't appear on the day the scheduled configuration has specified. If this happens, the job will be scheduled 7 or 29 days after the last executed job (7 for a weekly schedule, 29 for a monthly schedule).

The exported data is saved into a ZIP file that contains all the CSV files for the objects that were exported that are up to 512 MB in size. If the data you've exported is bigger than this, more ZIP files will be created.

You cannot make subsequent executions of Export Now jobs; you have to wait for the minimum time frame allowed for your organization (7 or 29 days). The exported files are available for 48 hours after their creation, after which the files are automatically deleted.