Hi ,
We have an interface SandboxPostCopy from salesforce.com to do data manipulation after sandbox is created or refresh.
It makes our sandbox environment business ready, automate data manipulation or business logic tasks.
At sandbox creation, specify a single Apex class to perform the tasks. This class executes every time the sandbox is copied.
Create an Apex class that implements SandboxPostCopy and specify the class here. For example, the following Apex class simply reports the three contexts available in SandboxPostCopy: your organization ID, sandbox ID, and sandbox name:
Example:
global class HelloWorld implements SandboxPostCopy { global void runApexClass(SandboxContext context) { System.debug('Hello Tester Pester ' + context.organizationId() + ' ' + context.sandboxId() + context.sandboxName()); } }
you can write your business logic in the method "runApexClass"
Reference:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_interface_System_SandboxPostCopy.htm?search_text=SandboxPostCopy#apex_interface_System_SandboxPostCopy_Example
https://docs.releasenotes.salesforce.com/en-us/spring16/release-notes/rn_deployment_sandbox_postcopy_script.htm