# Command Line

CopyStorm/Restore is generally used in GUI mode, but it is possible to run Copystorm/Restore as a command line application. This is useful for repetitive tasks such as:

* Refreshing 15 training Salesforce sandboxes in preparation for the next training class.

Prerequisites:

* A CopyStorm/Restore configuration file. This is the file saved by the GUI when selecting File -> Save As.

The simplest form of a CopyStorm/Restore command line is:

* Windows:
  * `CopyStormRestore.bat -run myConfig.copyStormRestore`
* Linux / Mac:
  * `sh CopyStormRestore.sh -run myConfig.copyStormRestore`

When running in command line mode CopyStorm/Restore will write progress and any errors encountered to stdout, in addition to the Tracker Database.

Often when CopyStorm/Restore is run in batch mode any history about past restores stored in the Tracker Database should be forgotten. The script that launches CopyStorm could delete the existing Tracker Database — and if so, Copystorm/Restore will automatically recreate it. However, a simpler solution is to use the `-restart` command-line switch. When the `-restart` switch is present, Copystorm/Restore will reset the Tracker Database before the restore begins. For example,

* Windows
  * `CopyStormRestore.bat -restart -run myConfig.copyStormRestore`
* Linux / Mac:
  * `sh CopyStormRestore.sh -restart -run myConfig.copyStormRestore`

## Command Line Reference

| Command Line Switch  | Description                                                                                                                               | Notes                                                                                                                                                                                                                                                                                                                                                                            |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -restart             | Reset the CopyStorm/Restore tracker database before starting the restore.                                                                 | This will delete all historical data in CopyStorm/Restore. Ids restored in previous jobs will no longer be available.                                                                                                                                                                                                                                                            |
| -scan                | Run a candidate scan before starting the restore.                                                                                         | This will search the CopyStorm database for any new records matching the Restore Set prior to starting the restore.                                                                                                                                                                                                                                                              |
| -resetSkippedReasons | Clear record skipped reasons before starting the restore.                                                                                 | This will delete all historical record skip reasons from the CopyStorm/Restore tracker database prior to starting the restore.                                                                                                                                                                                                                                                   |
| -deleteExceptions    | Clear historical exceptions before starting the restore.                                                                                  | This will delete all historical job exceptions from the CopyStorm/Restore tracker database prior to starting the restore.                                                                                                                                                                                                                                                        |
| -scanonly            | Run a candidate scan and do not start the restore.                                                                                        | This will search the CopyStorm database for any new records matching the Restore Set and add them to the CopyStorm/Restore tracker database, but will not restore to Salesforce.                                                                                                                                                                                                 |
| -run                 | Specifies the configuration file used to drive the restore.                                                                               |                                                                                                                                                                                                                                                                                                                                                                                  |
| -restoreType         | <p>Specifies the type restore to perform. Recognized values include:</p><ul><li>data (default)</li><li>metadata</li><li>tracker</li></ul> | <ul><li>data: Restore records to Salesforce, optionally scanning for new records to restore or removing Restore history prior to restoring.</li><li>metadata: Restore metadata to Salesforce.</li><li>tracker: Do not restore records to Salesforce. Only perform operations which impact the CopyStorm/Restore tracker database without uploading data to Salesforce.</li></ul> |
| -sftype              | <p>The type of Salesforce instance. Recognized values include:</p><ul><li>Production</li><li>Sandbox</li><li>DatabaseDotCom</li></ul>     |                                                                                                                                                                                                                                                                                                                                                                                  |
| -sfuser              | Salesforce username.                                                                                                                      | Note that this option can be used to override the Salesforce user name for both the classic and [SFDX Username credentials](https://learn.capstorm.com/copystorm/readme/frequently-asked-questions/usage/where-does-copystorm-store-passwords/how-to-login-to-salesforce-using-sfdx) type.                                                                                       |
| -sfpassword          | Salesforce password.                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                  |
| -sftoken             | Salesforce security token, if required by your organization.                                                                              |                                                                                                                                                                                                                                                                                                                                                                                  |
| -sfhost              | Salesforce host                                                                                                                           | If you use a custom domain like capstorm.my.salesforce.com specific it here. For scratch orgs a Salesforce host must always be specified.                                                                                                                                                                                                                                        |
| -dbuser              | CopyStorm database username.                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                  |
| -dbpassword          | CopyStorm database password.                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                  |
| -dbconnection        | CopyStorm database connection string.                                                                                                     |                                                                                                                                                                                                                                                                                                                                                                                  |
| -dbschema            | Schema Name                                                                                                                               | Override (or set) the database schema value in the configuration file.                                                                                                                                                                                                                                                                                                           |
| -proxyHost           | Host Name                                                                                                                                 | Override the proxy server in the configuration file. Example: proxy.capstorm.com                                                                                                                                                                                                                                                                                                 |
| -proxyPort           | Port Number                                                                                                                               | Override the port number used by the proxy server.                                                                                                                                                                                                                                                                                                                               |
| -proxyUser           | Username                                                                                                                                  | Override the username used to authenticate with the proxy server.                                                                                                                                                                                                                                                                                                                |
| -proxyPassword       | Password                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                                                                  |
| -apiTraceFile        | File Name                                                                                                                                 | Log all communication with Salesforce to a file.                                                                                                                                                                                                                                                                                                                                 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.capstorm.com/copystorm-restore/reference/command-line.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
