Q:

Retrieving all fields from Account and Case

How do I generate a package.xml of all the metadata (fields,permissions,profiles users etc') of Account and Case objects from Production/Sandbox ?
My goal is to push it to a scratch org using sfdx.
I tried generating it from here https://packagebuilder.herokuapp.com but the service is currently down, also tried to use Workbench to export the Account metadata using the Rest Explorer (/services/data/v45.0/sobjects/account/describe) but I'm not sure how to combine it with the case object.
Can someone point me to a tutorial? I don't need it to be done programmatically.

A:

You can retrieve DX-compatible formatted source using DX:
sfdx force:source:retrieve -u prod-login -m "CustomObject:Account,CustomObject:Case,Profile"

This should retrieve all the metadata you're asking for without the need for a package.xml, which you can then immediately turn around and push:
sfdx force:source:push -u scratch-org-login

You'll need to be in a project folder for this to work.
The full flow from start to finish would look like this:
cd ~/workspace
sfdx force:project:create -n my-project-name
cd my-project-name
sfdx force:auth:web:login -a prod-login
sfdx force:config:set defaultdevhubusername=prod-login
sfdx force:org:create -f config/project-scratch-def.json -s
sfdx force:source:retrieve -u prod-login -m "CustomObject:Account,CustomObject:Case,Profile"
sfdx force:source:push

