> For the complete documentation index, see [llms.txt](https://learn.capstorm.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.capstorm.com/reference/command-line.md).

# 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](/reference/configuration-files.md).

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
