# Command Line

CopyStorm provides a command line interface to enable CopyStorm to run under Windows Task Scheduler or CRON on Linux. Begin by creating a CopyStorm [configuration file](https://learn.capstorm.com/reference/configuration-files).

The following example Windows command line will run CopyStorm where:

* CopyStorm is installed in C:\CopyStorm.
* CopyStorm’s configuration file name is DemoCredentials.copyStorm.
* CopyStorm’s configuration file is located in C:\CopyStormDemo.
* The log file is redirected to a text document named C:\users\Mary\LogFile.txt.
  * This is optional.

```
CopyStorm.bat -run ../CopyStormDemo/DemoCredentials.copyStorm >c:/users/Mary/LogFile.txt
```

A similar command line for Linux or Mac will look like:

```
sh CopyStorm.sh -run ../CopyStormDemo/DemoCredentials.copyStorm >/home/mary/LogFile.txt
```

## Command Line Reference

| Switch          | Parameter         | Description                                                                                                                                                                     |
| --------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -sftype         | Sandbox           | Production                                                                                                                                                                      |
| -sfuser         | Username          | Override the Salesforce username in the configuration file.                                                                                                                     |
| -sfpassword     | Password          | Override the Salesforce password in the configuration file.                                                                                                                     |
| -sftoken        | Security Token    | Override the Salesforce security token in the configuration file.                                                                                                               |
| -dbconnection   | Connection String | Override the database connection string in the configuration file.                                                                                                              |
| -dbuser         | Username          | Override the database username in the configuration file.                                                                                                                       |
| -dbpassword     | Password          | Override the database password in the configuration file.                                                                                                                       |
| -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          | Override the password used to authenticate with the proxy server.                                                                                                               |
| -config         | Directory         | Search this directory for XML configuration overrides. Configurations in this directory will override those in the “config” subdirectory in CopyStorm’s installation directory. |
| -apiTraceFile   | Filename          | Record all messages to/from Salesforce in this file. Note that this will generate a very large file and is typically only useful when debugging problems with Salesforce.       |
| -debug          |                   | Write verbose debugging information, including SOQL statements sent to Salesforce, to stderr.                                                                                   |
| -modifiedSince  |                   | Set the of the Modified Since parameter, overriding any value in the configuration file.                                                                                        |
| -modifiedThru   |                   | Set the of the Modified Thru parameter, overriding any value in the configuration file.                                                                                         |
| -includedTables |                   | Set list of tables to include in the backup, overriding any value in the configuration file.                                                                                    |
| -excludedTables |                   | Set list of tables to exclude from the backup, overriding any value in the configuration file.                                                                                  |
| -forceTruncate  |                   | Truncate each table before it is backed up (creates a fresh copy of each table)                                                                                                 |

## Running a Snapshot Policy Headlessly

[Snapshot policies](https://learn.capstorm.com/reference/archive-tab) can be executed from the command line without opening the CopyStorm UI. Use the `-snapshot` switch in place of `-run`:

**Windows:**

```
CopyStorm.bat -snapshot "My Snapshot Policy" -snapshotThreads 5 -snapshotSearchBatchSize 5000 -snapshotWriteBatchSize 5000 -snapshotScanRecordsFrom "2023-01-01" -snapshotScanRecordsThru "2024-01-01" >C:\logs\snapshot.txt
```

**Linux/Mac:**

```
sh CopyStorm.sh -snapshot "My Snapshot Policy" -snapshotThreads 5 -snapshotSearchBatchSize 5000 -snapshotWriteBatchSize 5000 -snapshotScanRecordsFrom "2023-01-01" -snapshotScanRecordsThru "2024-01-01" >/home/jake/snapshot.txt
```

| Switch                   | Parameter   | Description                                                              |
| ------------------------ | ----------- | ------------------------------------------------------------------------ |
| -snapshot                | Policy Name | Name of the snapshot policy to run.                                      |
| -snapshotThreads         | Count       | Number of objects to snapshot concurrently.                              |
| -snapshotSearchBatchSize | Batch Size  | Number of records read from the database per search batch. Default: 1000 |
| -snapshotWriteBatchSize  | Batch Size  | Number of records written to the database per batch. Default: 1000       |
| -snapshotScanRecordsFrom | Date        | Limit snapshot to records modified on or after this date (YYYY-MM-DD)    |
| -snapshotScanRecordsThru | Date        | Limit snapshot to records modified on or before this date (YYYY-MM-DD)   |

## CopyStorm Exit Codes

In command line mode CopyStorm returns these exit status codes:

* 0 = the run completed normally with no exceptions.
* 1 = the run completed but had one or more recoverable errors.
* 2 = the run may have completed but there are exceptions that need investigation.
* 2 = credential or license error — one of:
  * Salesforce or database credentials are wrong.
  * Your CopyStorm license has expired


---

# 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/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.
