How to set up Salesforce Data Loader Command Line Interface or CLI?

1. Navigate to Setup –> Data –> Data Loader.

2. Download the data loader.

3. Install it following the wizard.

Make sure Command Line Tools and Samples option are selected in the wizard.

4. Make sure JAVA is installed in your machine by running "java -version" command on your Command Prompt Window.

5. Navigate to Program Files --> Data Loader --> bin in command prompt and run encrypt.bat –k. It will generate dataLoader.key file.

6. Run encrypt.bat -e YOURORGPASSWORD "KeyFileLocation\.dataloader\dataLoader.key" to get the password in encrypted form.

7. Create DataLoaderFiles folder or create a folder with your name choice outside Program Files folder. In my case I have created in C drive. Path is C:\DataLoaderFiles.

8. Navigate to C:\Program Files (x86)\\Data Loader\samples\conf to get some sample sdl files. Update it as per your request.

9. Create the mapping file by putting the CSV file header name on left side and Salesforce API name on right side. Move the mapping file to  C:\DataLoaderFiles location. I have used the below sdl file for extracting account.

  1. #Mapping values for Account Extract  
  2. Id=Id  
  3. Name=Name  

Make sure to add all the fields you are trying to retrieve it in the sdl file.

10. Navigate to C:\Program Files (x86)\\Data Loader\samples\conf to get process-conf.xml file.

11. Move the process-conf file to  C:\DataLoaderFiles location.

12. Edit the file and enter your information.

  1. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "">  
  2. <beans>  
  4.     <bean id="csvAccountExtractProcess"  
  5.           class="com.salesforce.dataloader.process.ProcessRunner"  
  6.           singleton="false">  
  7.       <description>csvAccountExtract job gets account info from salesforce and saves info into a CSV file."</description>  
  8.         <property name="name" value="csvAccountExtract"/>  
  9.         <property name="configOverrideMap">  
  10.             <map>  
  11.                 <entry key="sfdc.debugMessages" value="false"/>  
  12.                 <entry key="sfdc.debugMessagesFile" value="C:\DataLoaderFiles\sfdcSoapTrace.log"/>  
  13.                 <entry key="sfdc.endpoint" value=""/>  
  14.                 <entry key="sfdc.username" value="YOUR USERNAME"/>  
  15.                 <entry key="sfdc.password" value="ENCRYPTED PASSWORD"/>  
  16.                 <entry key="process.encryptionKeyFile" value="C:\Users\magulan\.dataloader\dataLoader.key"/>  
  17.                 <entry key="sfdc.timeoutSecs" value="600"/>  
  18.                 <entry key="sfdc.loadBatchSize" value="200"/>  
  19.                 <entry key="sfdc.entity" value="Account"/>  
  20.                 <entry key="sfdc.extractionRequestSize" value="500"/>  
  21.                 <entry key="sfdc.extractionSOQL" value="SELECT Id, Name FROM Account"/>  
  22.                 <entry key="process.operation" value="extract"/>  
  23.                 <entry key="process.mappingFile" value="C:\DataLoaderFiles\accountExtractMap.sdl"/>  
  24.                 <entry key="dataAccess.type" value="csvWrite"/>  
  25.                 <entry key="" value="C:\DataLoaderFiles\extract.csv"/>  
  26.             </map>  
  27.         </property>  
  28.     </bean>  
  30. </beans>  

Make sure to add all the fields you are trying to retrieve it in the extractionSOQL attribute. Make sure the sdl file also have those fields for the mapping.

13. Put process-conf and mapping sdl file into the new folder. In my case I have used C:\DataLoaderFiles.

14. Run process C:\DataLoaderFiles csvAccountExtractProcess to extract the data.
Make sure you are in Data Loader's bin folder to execute the command from the Command Prompt.