Sub topic 5
Partial Copy and Full sandboxes
This chapter assumes you know the difference between metadata (configuration and code) and data (records). It also assumes you have seen the Developer and Developer Pro sandboxes from the previous chapter. Partial Copy and Full sandboxes are the two types that can hold production data, so most of their behavior comes down to how much data they copy and how that copy is chosen.
What the two types have in common
Every sandbox copies all of production's metadata: objects, fields, flows, Apex classes, page layouts, and so on. The types differ in what they copy of the data.
- A Developer or Developer Pro sandbox copies no records.
- A Partial Copy sandbox copies metadata plus a sample of records.
- A Full sandbox copies metadata plus all records.
Because these two types carry real business data, they suit work that needs realistic content: user acceptance testing (UAT), integration testing, training, and performance testing. They also come with longer refresh intervals and longer creation times.
Partial Copy sandboxes
A Partial Copy sandbox is a sandbox that holds your metadata and a sample of your production data. The sample is defined by a sandbox template, which you build before you create the sandbox. A template lists the objects whose records you want. You cannot create a Partial Copy sandbox without one.
Key properties:
- Data copied: records for the objects in the template, up to 10,000 records per selected object.
- Data storage limit: 5 GB.
- File storage limit: same as your production org.
- Refresh interval: 5 days.
How the sample behaves
The sample is a subset. If you select Account and Opportunity, you get at most 10,000 accounts and 10,000 opportunities. They are not guaranteed to be the specific records your tests mention. A test script that says "open the Acme account" can fail simply because Acme was not in the sample.
Plan for this in three ways:
- Keep test scripts independent of specific production records. Have them create the records they need.
- Select every object your scenario depends on. A template that omits an object gives you an empty object in the sandbox.
- Check the counts after the sandbox is created, before you hand it to testers.
A quick check you can run in Developer Console anonymous Apex:
System.debug('Accounts: ' + [SELECT COUNT() FROM Account]);
System.debug('Opportunities: ' + [SELECT COUNT() FROM Opportunity]);
System.debug('Contacts: ' + [SELECT COUNT() FROM Contact]);Compare the output with what your test plan requires.
Full sandboxes
A Full sandbox is an exact copy of production: all metadata and all data, including attachments and files. It is the only type that can reproduce production volumes.
Key properties:
- Data copied: all records, with an optional template to limit which objects are included.
- Data storage limit: same as production.
- File storage limit: same as production.
- Refresh interval: 29 days.
Optional data in a Full sandbox
When you create or refresh a Full sandbox, Salesforce asks whether to include certain high-volume data, such as field tracking history and Chatter data. Leaving these out makes the copy faster and smaller. Include them only when your tests need them, for example when you are validating a report built on field history.
Why Full sandboxes take longer
Copy time grows with the amount of data. A Full sandbox of a large org can take many hours, and sometimes longer. A Partial Copy sandbox usually finishes sooner because its sample is capped. Neither type gives a guaranteed finish time, so do not schedule a test cycle to start the moment you request a copy.
Comparison
The table below puts all four types side by side so you can see where Partial Copy and Full sit.
| Type | Data copied | Data storage | Refresh interval |
|---|---|---|---|
| Developer | Metadata only | 200 MB | 1 day |
| Developer Pro | Metadata only | 1 GB | 1 day |
| Partial Copy | Metadata and a sample defined by a template | 5 GB | 5 days |
| Full | Metadata and all data | Same as production | 29 days |
Using these types in a release path
Full and Partial Copy sandboxes usually sit near the end of a deployment path, after developers finish work in Developer sandboxes.
Each step uses a sandbox whose data matches the kind of test being run. Small sample data is enough for functional QA. Production-size data is needed to find slow queries, governor limit problems, and long-running batch jobs.
Decision criteria
Choose Partial Copy when:
- Testers need realistic-looking records but not every record.
- You can describe the needed objects in a template.
- A 5-day refresh cycle fits your sprint rhythm.
Choose Full when:
- You need production data volume, for example for performance or load testing.
- You need to reproduce a bug that depends on specific production records or history.
- You want a staging environment that mirrors production before a release.
Do not choose a larger type than you need. Full sandboxes are a limited, licensed resource, and a 29-day refresh interval means a mistake in the environment costs you nearly a month.
Gotchas and failure modes
- The refresh interval is a hard wait. After you create or refresh a Full sandbox, you cannot refresh it again for 29 days. If you wipe out test configuration by refreshing early in a release window, you cannot undo it by refreshing again.
- A sample is not a mirror. Partial Copy data may lack parent or related records you expect. Records in the sandbox that refer to records outside the sample can show blank or missing lookups.
- Storage can fill up. A Partial Copy sandbox has a 5 GB data limit. Bulk-loading test data on top of the copied sample can reach it. A Full sandbox shares production's size, so it is always near full if production is.
- Production data means production risk. A Full or Partial Copy sandbox holds real customer information. Mask or scramble sensitive fields in your post-copy setup, and restrict who has access. A later chapter shows how to automate this with a
SandboxPostCopyclass. - Emails can reach real people. Sandbox email deliverability is reduced by default after a copy. Do not re-enable it for all emails while real addresses are in the data unless you intend to send them.
Creating one from the command line
You can also create a Full sandbox with the Salesforce CLI, using a definition file. The licenseType value sets the sandbox type.
{
"sandboxName": "staging",
"licenseType": "Full"
}sf org create sandbox --definition-file config/sandbox-def.json --alias staging --target-org prodThe command assumes production is already authorized with the alias prod. A later chapter covers the CLI in more detail.
Practice
Exercise
Your team needs to load-test a nightly batch job against production-scale data, and also wants a sandbox where testers can run UAT with a small set of realistic accounts. Which sandbox type fits each need, and how long must you wait before you can refresh each one again?
Show answer
Use a Full sandbox for the load test, because only a Full sandbox copies all production data at production volume. Its refresh interval is 29 days. Use a Partial Copy sandbox for UAT, because a template can select the Account and related objects with up to 10,000 records per object. Its refresh interval is 5 days.
Exercise
A tester reports that the "Acme" account exists in production but not in the Partial Copy sandbox, even though Account was in the template. Why can this happen, and what is the best way to avoid test failures from it?
Show answer
A Partial Copy sandbox copies only a sample, up to 10,000 records per selected object, so any specific record may be left out. Avoid the problem by writing tests that create their own records, or by choosing a Full sandbox if the tests depend on particular production records.