1.Clone the sandbox
By far, the easiest way to back up your sandbox is to clone it. By cloning the sandbox, you create a new one with the exact same metadata as the current one.
Then, you can refresh your original sandbox.
After the original sandbox is refreshed, use a change set to move the changes from the cloned sandbox over to the original one.
2.Download a change set with sfdx
Another way to back up your Salesforce sandbox before refreshing it is to create an outbound change set and add all the changes you want to back up.
Once the change set is created, you can download its contents with sfdx (really).
Here's the command you need to run
sfdx force:source:retrieve -n [MyChangeSetName]
This is a good option if you are not interested in backing up the entire sandbox but just some metadata that is part of a project or feature you are working on.
Once the sandbox is refreshed, connect to it with sfdx, and run the following command to deploy the change set contents back to it
sfdx force:source:deploy -p [folder-where-changeset-was-retrieved]
3.Download the entire sandbox with sfdx
The third way is similar to the previous one, except here, we retrieve the entire metadata of your Sandbox.
-> sfdx command that allows you to retrieve all the metadata in the org without having to know beforehand what metadata types you have,
which fields to include, etc.
First, we'll run a command to generate a package.xml file that includes every single metadata item in your org
sfdx force source manifest create --fromorg [your org alias] --manifestname=allMetadata --outputdir manifest
Once you run this command, you'll see allMetadata.xml file under the manifest directory:
You'll notice this file lists all the metadata in your org!
The next step is simply to right-click the file, and select "Retrieve source in manifest from Org"
And that's it! Now all your Salesforce metadata is in the sfdx project.
Note :
That said, I got some feedback from the community that this command times out if your org is huge.
I also found that some of the metadata that is retrieved cannot be deployed back.
For this reason, I recommend options 1 and 2 first.
4.Use an appexchange app for metadata backup
The final way to back up your sandbox is to use an app from the Salesforce appexchange.
ex: Salto
No comments:
Post a Comment