1

I do understand that a dev sandbox can be refreshed from a production org via the Setup UI.

However, I want to be able to refresh my dev sandbox with the production org GIT repo (SFDC_REPO) so I can start my changes before merging back to the SFDC_REPO master branch.

  1. How can I do a refresh of my dev sandbox using ANT so that it is a complete wipe clean and replaced with the source code (and metadata) checked out from SFDC_REPO ?

    Would it be a "destructive" deploy ANT task & how would I generate the package.xml file for such a complete wipe & replace of the the dev sandbox ?

  2. If I did this refresh using Force IDE | Save to Server - would it achieve the same effect as the destructive deploy ANT task above ? Would Force IDE deploy only the components that have been changed when in performs Save to Server ?

Your ideas are much valued :)

1

How can I do a refresh of my dev sandbox using ANT so that it is a complete wipe clean and replaced with the source code (and metadata) checked out from SFDC_REPO?

Would it be a "destructive" deploy ANT task & how would I generate the package.xml file for such a complete wipe & replace of the the dev sandbox ?

You can't. Destroying anything is hard enough, trying to wipe an entire org could take hundreds or thousands of tries to get it right. Once. You'd be stuck each and every time trying to resolve dependencies to the point where refreshing daily would be less painful.

If I did this refresh using Force IDE | Save to Server - would it achieve the same effect as the destructive deploy ANT task above ? Would Force IDE deploy only the components that have been changed when in performs Save to Server ?

Yes, the Force.com IDE can calculate deltas and try to deploy changes. However, it's not particularly efficient in doing so, and you still risk getting a lot of errors. It'd be better to do small, incremental changes, and you'd still have to hope for the best. There's a nice GUI, so it's better than doing it by hand (above), but not a practical solution.


There are two possible alternatives.

Using the SandboxProcess object, you can create a new Sandbox using the API. This is the identical behavior of using the UI, but without the UI. However, this leaves you with the problem from above, refreshing the org using git-managed metadata. It's still basically a problem.

So, of course, the actual answer is to use Salesforce DX. Salesforce DX allows you to spin up a brand-new, completely empty org, then push all of your metadata from a git branch directly into that org, and then track changes that are made in that org so you can pull them back to git.

Currently, there's challenges for very large orgs (those with more than a few thousand customizations) or orgs that use special features (not all features can be managed in source), but if you're a pretty vanilla org, DX is the way to go. You may as well at least start learning about Salesforce DX, because it is likely you'll want to use this feature in the future.

For example, in our org, it usually takes about 2 hours for a refresh, but using DX (minus the features we can't enable yet), we can go from nothing to a fully fleshed out replica of any branch we have in about 10-15 minutes, which includes installing a dozen AppExchange apps and some odd 9,800 artifacts and thousands of records of data. While it's not perfect for our use yet, we've seen the potential, and we're looking forward to the day we can use it effectively.

| improve this answer | |
  • Appreciate your sharp insights. DX is next on the TODO list for sure. However, my current work place is using ANT and Force IDE so I just need to get a stable workflow going. Are you saying that: it is not feasible to refresh a developer sandbox with metadata stored in a GIT repo so that it is reflects the latest version of the production org (given that the data & production org settings which cannot be carried over to sandboxes) ? I would think that - getting a dev sandbox to reflect the latest version of product org for dev - is a very common use case ! Am I expecting too much? – Tickle Me May 30 '18 at 6:07
  • @TickleMe Not using Force.com IDE or Ant. What you need is an intelligent tool. At our place, we're using GearSet, and our deployment person loves it, as GearSet can automatically detect changes in metadata and apply additions, updates, and deletions automatically. I've also heard good things about AutoRabit. Of course, you can, and should, do your own research on which tool is right for you. Yes, you'll have to pay more money, but it definitely beats having to try and do it manually. Try to get to DX soon as you can, though. – sfdcfox May 30 '18 at 6:14

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.