Here I am going to show case a small POC of Data migration using Salesforce DX, its really easy to use, and the process where you want to maintain the test data in different-different Sandbox, then Salesforce DX is for you.
So lets get started,
Before going further, if you have not installed Salesforce DX in your system and please go ahead and install it you system.
Here is the Trailhead link where you can find link to install and get to know more about SalesforcDX.
After installing open the git bash and check whether SalesforceDX got successfully installed or not.
So let me explain you a bit about this process using dx, here we will use two sandbox, one from where we will export the data and the other is the destination sandbox where we will import the data, now this is the first time process, where we are exporting the data from one sandbox, but if its recurring process then we will have the data in JSON format in our local machine, so we just need to export it to other sandboxes.
Please enter
$ sfdx force
If it show the cloud image made up of DX then its installed, now we will create a project first.
$ sfdx force:project:create -n web //create project, its not necessary you can skip this one also
//Add a new sandbox , on hitting this command it will ask you to login to you sandbox and authorize
$ sfdx force:auth:web:login --setalias my-sandbox --instanceurl https://salesforce.com
//after this do the same thing again and add another sandbox.
//Now if you want to check how many orgs you have added you can by below command
$ sfdx force:org:list
//you have to define an org as default to so that dx will fetch the data from that org. use below for the same
$ sfdx force:config:set defaultusername=abhi@sfdx.com.cloudy --global
//now export the data, here we are exporting only account data, but you can do allot more then this
$ sfdx force:data:soql:query --query "Select Id, Name From Account"
If you'll check that file that DX has created will have the content something like below
In the command prompt you'll be able to see the data count as well.
Now to import the data to another sandbox, you just have to hit another command, as its so easy so here are the things need to consider before hitting the command
1. Define the correct source path of the JSON file.
2. Provide the correct sanbox username.
3. Sandbox should be from the list of the sandbox added in the DX.
//to import data to sandbox
$ sfdx force:data:tree:import --targetusername abhi-tripathi@sfdx.com.cloudy--plan sfdx-out/export-demo-Account-plan.json
Your command prompt
Woohoo!! you have just performed the data migration using SalesforceDX
Here are some links that will be helpfull
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_dev_model
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_test_data_example.htm
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_usernames_orgs.htm
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_app_dev
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_travis_ci
https://www.youtube.com/watch?time_continue=1596&v=exZ3TICOzd8
Thanks you!!
So lets get started,
Before going further, if you have not installed Salesforce DX in your system and please go ahead and install it you system.
Here is the Trailhead link where you can find link to install and get to know more about SalesforcDX.
After installing open the git bash and check whether SalesforceDX got successfully installed or not.
So let me explain you a bit about this process using dx, here we will use two sandbox, one from where we will export the data and the other is the destination sandbox where we will import the data, now this is the first time process, where we are exporting the data from one sandbox, but if its recurring process then we will have the data in JSON format in our local machine, so we just need to export it to other sandboxes.
Please enter
$ sfdx force
If it show the cloud image made up of DX then its installed, now we will create a project first.
$ sfdx force:project:create -n web //create project, its not necessary you can skip this one also
//Add a new sandbox , on hitting this command it will ask you to login to you sandbox and authorize
$ sfdx force:auth:web:login --setalias my-sandbox --instanceurl https://salesforce.com
//after this do the same thing again and add another sandbox.
//Now if you want to check how many orgs you have added you can by below command
$ sfdx force:org:list
//you have to define an org as default to so that dx will fetch the data from that org. use below for the same
$ sfdx force:config:set defaultusername=abhi@sfdx.com.cloudy --global
//now export the data, here we are exporting only account data, but you can do allot more then this
$ sfdx force:data:soql:query --query "Select Id, Name From Account"
If you'll check that file that DX has created will have the content something like below
{ "records": [ { "attributes": { "type": "Account", "referenceId": "AccountRef1" }, "Name": "Sinclair Community College" }, { "attributes": { "type": "Account", "referenceId": "AccountRef2" }, "Name": "The Institute of Electrical and Electronics Engineers, Inc." }, { "attributes": { "type": "Account", "referenceId": "AccountRef61" }, "Name": "TestLastName" } ] }
In the command prompt you'll be able to see the data count as well.
Now to import the data to another sandbox, you just have to hit another command, as its so easy so here are the things need to consider before hitting the command
1. Define the correct source path of the JSON file.
2. Provide the correct sanbox username.
3. Sandbox should be from the list of the sandbox added in the DX.
//to import data to sandbox
$ sfdx force:data:tree:import --targetusername abhi-tripathi@sfdx.com.cloudy--plan sfdx-out/export-demo-Account-plan.json
Your command prompt
Woohoo!! you have just performed the data migration using SalesforceDX
Here are some links that will be helpfull
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_dev_model
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_test_data_example.htm
https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_cli_usernames_orgs.htm
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_app_dev
https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_travis_ci
https://www.youtube.com/watch?time_continue=1596&v=exZ3TICOzd8
Thanks you!!