ANT Script For Data Migration

ANT Script for Meta Data Migration :

It is a command-line script which is based on java and is used to migrate metadata between two connected(sandbox and production) or non connected Salesforce organization.

Advertisement

How to insatll ANT in your system :

1. First the latest version of java must be installed in your system, to check java, open the command prompt and run the script java -version

java version

if java is installed then you are good to go with the ANT installation else install java from http://www.oracle.com/technetwork/java/javase/downloads/index.html

How to Install and configure ANT :

1. First step is to Download the Apache Ant version 1.6 or greater from http://ant.apache.org/bindownload.cgi. This directory will be known as ANT_HOME.

Apache Ant version

2. Now Add the bin directory to your path in enviornmnet variable for windows.

3. Create an ANT_HOME environment variable and set the path where ant is installed

ANT_Home

4. Create an ANT_HOME environment variable and set the path where java bin folder is installed.

Java Home

Check if ANT is installed or not :

1. Open terminal or Command prompt

2. Type ANT -version and press enter

ANT-version

Installing Force.com Migration Tool for windows :

1. Login into your salesforce organization

2. Go to setup > Develop > Tools and select Force.com Migration Tool

Salesforce build

Salesforce Supported Tools

3. Next step is to download and save the .zip file and extract it.

4. After extraction , copy the "ant-salesforce.jar" file and paste it in your Apache Ant lib directory.

Installing Force.com Migration Tool For LINUX enviorment

1. Open the terminal by pressing Ctrl+Alt+T

2. Just run the script sudo apt-get install apache-ant-1.9.4-bin.tar.gz and you are done.

Setting up the connection Information with salesforce :

1. Open the folder named "Salesforce_ant".

2. Now open the folder named as "sample"

3. In "sample" folder , first open up "build.properties" file to set the saleforce connection, So in build file there are three things which are required to complete the connection.

sf.username, sf.password and sf.serverurl.

Setting Up Connection

Note : For successful connection you device IP must be white listed in the org in which you are trying to retrieve or deploy.

4. After setting up the build file open the folder "unpackaged" in that open the xml file which looks like this :

Salesforce Data Migration

5. After setting up the package file, go to the terminal, set the path to the sample folder like below :

Data Migration

6. After this , type "ant retrieveUnpackaged" and press enter then check the folder "retrieveUnpackaged" in sample and it look like this.

Data Migration in Salesforce

Note : It's a best practice to delete the folder retrieveUnpackaged every time "ant retrieveUnpackaged" command is executed.

7. Once retrieved open up "build.poperties" file and update the fields sf.username, sf.password and sf.serverurl for the target org.

8. After this type "ant deployUnpackaged" in terminal to deploy the retrieved package to the target org.

Popular Salesforce Blogs