Friday 22 August 2014

ANT SCRIPT TO TAKE DATA BACKUP FROM SALESFORCE ORGANIZATION

                To Take Data Backup by using Apache Ant

 Follow Bellow Steps : 

1. Login to Sales force Instance

2. Go To Set-up>Develop>Tools to download Force.com Migration Tool to your C:\Drive and extract it

3. Go To C:\salesforce_ant_31.0\sample\build.properties
  
   1. sf.username = xxxxxxxxxxx.com
  
   2. sf.password = xxxxxxxxxxx + secuirty Token
  
   3. sf.pkgName = your salesforce package name
  
   4. sf.serverurl = https://login.salesforce.com (If sandbox give your sales force sandbox instance)
  
   5. sf.maxPoll = 20

4. Go To C:\salesforce_ant_31.0\sample\build.xml
   
    1. If your system is in proxy then flow step one
   
        Copy this code and add at end
       
        <target name="checkproxy">
            <setproxy proxyhost="xxxxxxxxxxxxxx" proxypassword="" proxyport="xxxxxx" proxyuser=""/> (Give your proxyhost and proxyport)
        </target>
       
    2. /*Replace the retrievepkg section with the following one*/
   
        <!-- Retrieve metadata for all the packages specified under packageNames -->
        <target name="retrievePkg" depends="checkproxy">
            <mkdir dir="retrievePkg"/>
            <sf:retrieve username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" maxPoll="${sf.maxPoll}" retrieveTarget="retrievePkg" packageNames="${sf.pkgName}"/>
        </target>
       
5. Download Ant and Install it from http://ant.apache.org/bindownload.cgi if you do not have it (Setting up Ant_Home and Configure Path environment variable)

    a.    Download Apache Ant version 1.6 or newer to a directory of your choice: http://ant.apache.org/bindownload.cgi.
   
    b.    This directory will be known as ANT_HOME. Once the files are on your computer, there is no further installation required.
   
    c.  Add the bin directory to your path. (Only the bin and lib directories are required to run Ant.)
   
    d.    set JAVA_HOME=c:\jdk1.7.0_51
   
    e.    set PATH=%PATH%;%ANT_HOME%\bin
   
6. Copy ant-salesforce.jar and paste into your Ant installation's lib directory. The lib directory is located in the root folder of your Ant installation.

7. Run The Following Command

    open the command prompt and type
   
    C:\Users\shimran>ant -buildfile C:\salesforce_ant_31.0\sample\build.xml retrievePkg
   
    [-----------------------------------------------
    Buildfile: C:\salesforce_ant_31.0\sample\build.xml

    checkproxy:

    retrievePkg:
        [mkdir] Created dir: C:\salesforce_ant_31.0\sample\retrievePkg
    [sf:retrieve] Using proxy: web-proxy.sgp.hp.com:8080 user
    [sf:retrieve] Using proxy: web-proxy.sgp.hp.com:8080 user
    [sf:retrieve] Request for a retrieve submitted successfully.
    [sf:retrieve] Request ID for the current retrieve task: 09S90000001Hb1qEAC
    [sf:retrieve] Waiting for server to finish processing the request...
    [sf:retrieve] Request Status: InProgress
    [sf:retrieve] Request Status: Succeeded
    [sf:retrieve] Finished request 09S90000001Hb1qEAC successfully.

    BUILD SUCCESSFUL
    Total time: 1 minute 6 seconds
    -----------------------------------------------]
   
8. Now Go To Csalesforce_ant_31.0\sample\retrievePkg  (Your Back Up Data Is Here)

-----------------------------------------------------------------------------------------------------

How To Create Package In Salesforce :


1. Go To Set-up>Create>Packages>New

    a. Give your  package Name
   
    b. Language
   
2. Click Add

3. Select what data You want to take back up  and add to package