0

I would like to set up a daily backup of all the Apex classes and triggers. Is there any way this can be done using the cli (sfdx)? If not, are there any other ways?

The idea is to write a script that would commit the changes to a git repository.

  • There are vendor $$ DevOps solutions that will do this (and a lot more) - e.g. Gearset, Blue Canvas, ... – cropredy Oct 3 '19 at 21:22
  • 1
    If you already know what the classes are, build a package.xml and just do sfdx force:mdapi:retrieve --retrievetargetdir . -u yourusername@whatever -k package.xml. Then commit that. if you don't know what the classes are, use the metadata api to retrieve them. I am lazy and don't have an automated way to do that, so i use the package builder web app: packagebuilder.herokuapp.com It is open source so you may be able to get the bits you need. It is written in Python, however. – zaitsman Oct 3 '19 at 23:57
1
  1. Create package.xml; can be done programatically using Metadata API. For one time generation: packagebuilder.herokuapp.com
  2. sfdx force:mdapi:retrieve --retrievetargetdir . -u yourusername@whatever -k package.xml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.