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.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI 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.
sfdx force:mdapi:retrieve --retrievetargetdir . -u yourusername@whatever -k package.xml
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