I have been trying to achieve this goal for weeks. The closest I can get is using the following steps:

sfdx force:project:create -n myproject
cd myproject
mkdir temp
sfdx force:mdapi:retrieve -s -r ./temp -u production -k ../package.xml
unzip ./temp/unpackaged.zip -d ./temp/
sfdx force:mdapi:convert -r ./temp

As a final step I tried running both source push

sfdx force:source:push -u scratchorg

And source deploy

sfdx force:mdapi:deploy -g -o -u scratchorg -d .

I keep getting thousands of errors , some of the errors :

Invalid fullName, must end in a custom suffix ( for ex. __c )

Can't specify an external sharing model for Opportunity

Must specify a non-empty label for the CustomObject

Could not resolve standard field's name. (136:13)

And many more error.

Is there any way to successfully copy production org into a scratch org ?


I'm afraid that currently (07.05.2019) it is not possible to easy copy production to scratch org.

What you are trying to achieve will be introduced when Shape Orgs (which will be Scratch Orgs that will be copy of the Production settings) would be GA. Currently they are in Pilot and looking at this site it is not possible to sign for tests currently. More resources about shape orgs are here and here.

How you can achieve it currently:

You need to create Scratch org with exact same settings and features enabled like in your Production org. After that you need to do more or less exact steps that you did already but unfortunately SFDX is still a little bugged so you'll need to try fix everything one by one manually in most cases. For example:

Can't specify an external sharing model for Opportunity

This error is probably caused by not enabling external sharing model on your scratch org.

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.