ABSYZ ABSYZ

  • Home

    Welcome to ABSYZ

  • About us

    Who We Are

  • Our Expertise

    What We Do

  • Our Approach

    How We Do It

  • Products

    What We Made

  • Industries

    Who We Do It For

  • Clients

    Whom We Did It For.

  • Article & Blogs

    What Experts Think

  • Careers

    Join The Team

  • Get In Touch

    Let’s Get Started

ABSYZ

Automate metadata backup of your Salesforce org with the help of ANT and GIT

Home / Article & Blogs / Salesforce / Automate metadata backup of your Salesforce org with the help of ANT and GIT

Automate metadata backup of your Salesforce org with the help of ANT and GIT

By Aquib Javed inSalesforce, Uncategorized

When working with a team on a Project , the situation often arises that more than one person end up working on the same class and overwrites each other code. This could turn into a nightmare if you  don’t have a backup of the org to refer to and merge the changes.

We faced the same situation in one of the project I was working on , and I took it upon myself to find a better way to take metadata backup rather than manually taking it in eclipse or any other IDE.While looking for a way for this I stumbled across an excellent post by Douglas C. Ayers Blog Post. This blog post is an extension of the same.

Pre-requisite:

Java version 1.6 or higher

Part 1:- Setting up ANT

1) Download the latest version of ANT from Apache ANT project  and extract it in a folder of your choice. This will be your ANT_HOME environment variable.
How to set up an environment variable

Apache ANT
1

ANT_HOME

2

2) Login to your Salesforce org and go to the following address.
Salesforce migration tool to download Salesforce Migration Tool and extract it in a folder.
You will find a Salesforce.jar file in the extracted file. Copy it and paste it in the ‘lib’ folder of Ant home directory.

3) Set up an Environmental Variable for bin folder of your Ant directory , call it Path.

4.PNG

4) Check whether ANT is installed properly:
Open your command prompt and type ant –version to check the version of the ANT installed in your machine

CMD

 

5) Define Project Properties:
For this ANT uses 3 files ( build.properties, build.xml & package.xml) all 3 could be found in the sample folder of the folder extracted in step 2. Copy all three files in a separate folder in which you intend to take your code backup.  Make appropriate changes in these files e.g : Your salesforce login and password, what components you want to extract etc.

Part 2:  Create a project and Push to Git

 

1) Retrieve your metadata mentioned in package.xml by going to the folder in which you saved these files in command prompt and type the below command

ANT retrieveCode

2) The previous step will fetch the metadata from your Salesforce org to your local machine. Now you need to create a Git repository in which you have to push and commit this project. Refer the guide in the below link to check details on how to do it.

https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

 

Part 3: Schedule your metadata retrieval.

1) You can write a shell script which will run on system startup to retrieve your code from salesforce org and pushing it to your Github repository.

2) Your shell script would look something like this :

[code language=”java”]

@echo OFF
cd C:/
git add .
git commit -am “Daily Sandbox backup”
git push -v -u
echo Git operation Done
cd ..
ant retrieveCode

[/code]
Add the above file as .cmd

3) Go to your “Run” Dialog box by pressing windows and R keys together and type shell:startup.
A folder will open , In this folder paste your script file.

 

Now, whenever your system boots ANT will retrieve your metadata and then you will push it to your repository.

ANTAutomateBackupGitHubMetaData
32
Like this post
4 Posts
Aquib Javed

Search Posts

Archives

Categories

Recent posts

Significance of UI/UX Design

Significance of UI/UX Design

Cyber-security in an uncertain world

Cyber-security in an uncertain world

The world of AR and VR

The world of AR and VR

The in-and-out of ML

The in-and-out of ML

Future of Mobility

Future of Mobility

  • Previous PostWorkAround for PDF Rendering in SF1
  • Next PostCreate Lightning Charts With Chart.Js

Related Posts

REST API call from Einstein Analytics Dashboard
Apex REST Salesforce Salesforce Einstein Wave Analytics

REST API call from Einstein Analytics Dashboard

Create/Update Salesforce Picklist definitions using metadata API
Integration Metadata API Salesforce

Create/Update Salesforce Picklist definitions using metadata API

Leave a Reply (Cancel reply)

Your email address will not be published. Required fields are marked *

*
*

ABSYZ Logo
  • Home
  • About us
  • Article & Blogs
  • Careers
  • Get In Touch
  • Our Expertise
  • Our Approach
  • Products
  • Industries
  • Clients
  • White Papers

ABSYZ Software Consulting Pvt. Ltd.
USA: 49197 Wixom Tech Dr, Wixom, MI 48393, USA
M: +1.415.364.8055

India: 6th Floor, SS Techpark, PSR Prime, DLF Cyber City, Gachibowli, Hyderabad, Telangana – 500032
M: +91 79979 66174

Copyright ©2020 Absyz Inc. All Rights Reserved.

youngsoft
Copy