Scratch Org Snapshots
Did you know you can create scratch orgs based on already existing scratch org? This is possible thanks to the Scratch Org Snapshots feature.
Did you know you can create scratch orgs based on already existing scratch org? This is possible thanks to the Scratch Org Snapshots feature.
This is very useful when:
1. You have some steps that need to be performed on the scratch org every time you create it - e.g. managed package installation, test data population, manual config in the setup.
2. You are in the middle of the development and your scratch org is about to expire - just create a snapshot from it and your work will not be lost.
Let’s check how to create snapshots
Complete the prerequisites:
Enable Scratch Org Snapshots on your DevHub org (Setup -> Scratch Orgs -> Enable Scratch Org Snapshots) Make sure your user has CRUD object permissions on the Org Snapshot object Create an unnamespaced source scratch org and apply all the changes and configuration you wish to be included in the snapshot
Create the scratch org snapshot
sf org create snapshot --name snapshot --source-org your-snapshot-source-scratchCheck the creation status
sf org get snapshot --snapshot snapshotAdd snapshot reference to the scratch org config file
{
"orgName": "BTC Snapshot Demo",
"snapshot": "snapshot"
}Create a new scratch org based on the snapshot
sf org create scratch -a your-great-scratch -f .\config\project-scratch-def.json --wait 30Limitations to keep in mind
1. Snapshots expire after 90 days 2. You can only create snapshots based on scratch orgs without a namespace (but you can create a namespaced scratch org from the snapshot!) 3. You can create up to 5 snapshots daily per Devhub org 4. You can have up to 5 active snapshots per Devhub org


