All pages
1 of 84

Reference

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

SQL/Server Connection

Prior to running CopyStorm for the first time, create a fresh SQL/Server database.

SQL/Server Connection String

The only difficult part when copying Salesforce to SQL/Server is constructing the connection string. Clicking on the Connection String Builder will open a form that, if you are running SQL/Server using a standard configuration, will construct a connection string for you.

The connection string can be verified by pressing the “Test SQLServer Connection” button.

The general form of a SQL/Server connection string is:

  • [server-name[\instance-name][:port-number]][;property=value]*

If you would like to see more information regarding SQL/Server connection strings or are not familiar with Microsoft’s type 4 JDBC driver, these resources may help:

  • https://docs.microsoft.com/en-us/previous-versions/sql/legacy/ms378428(v=sql.90)

  • http://www.connectionstrings.com/

MySQL Connection

Capstorm includes a MySQL driver from the MariaDB project to communicate with both Oracle’s MySQL product and with MariaDB.

Since MariaDB is provided by the original authors of MySQL and strives to maintain compatibility with Oracle’s MySQL, the driver packaged with CopyStorm is probably the only driver you will need. However, if you are encountering compatibility issues or other problems with MariaDB’s MySQL driver, you can download and install Oracle’s MySQL driver by hand.

CopyStorm does not package this driver with the product due to Oracle’s licensing policy for ISV’s, which makes it difficult to package the Oracle MySQL JDBC driver with a product.

How to Install Oracle’s MySQL JDBC Driver (not recommended for most cases)

To install the Oracle MySQL JDBC driver:

  • Delete the file lib/mariadb-java-client-*.jar from the CopyStorm installation directory.

  • Restart CopyStorm.

  • Choose MySQL as the database type.

  • CopyStorm will ask you if it’s OK to download and install Oracle’s JDBC driver.

If you would prefer to install Oracle’s JDBC driver by hand:

  • Go to Oracle’s download page

    • http://dev.mysql.com/downloads/connector/j

  • Download and unzip the driver.

  • Copy the jar file to CopyStorm’s lib directory.

  • Restart CopyStorm

Common Problem – TCP/IP is not enabled

All MySQL JDBC drivers communicate with MySQL using TCP/IP. If CopyStorm is having trouble connecting to the MySQL database, you may not have TCP/IP enabled. If so, there are a number of resources providing instructions on enabling this feature (the manual for your version of MySQL, running a web search for “MySQL enable TCP”, etc…).

MySQL Connection String

The only complicated configuration required in the CopyStorm Main tab is the MySQL connection string. Clicking on the Connection String Builder button will open a form that will construct the connection string for you, given database information.

The connection string can be verified by pressing the “Test MySQL Connection” button.

The format of a MySQL connection string is:

  • //[host][:port]/[database-name]

Example:

  • //localhost/MyCopyStormDatabase

Oracle Connection

Initial Step

Prior to running CopyStorm for the first time, create a fresh Oracle database.

Oracle Connection String

The only complicated configuration required in the CopyStorm Main tab is the Oracle connection string. Clicking on the Connection String Builder button will open a form that will construct the connection string for you, given database information.

You will likely need one of these forms:

  • myDomain.com:1521:orcl

  • myDomain.com:1521:xe

  • localhost:1521

The connection string can be verified by pressing the “Test Oracle Connection” button.

The following is a screen shot of a working Oracle setup on one of our test computers:

PostgreSQL Connection

Initial Steps

Prior to running CopyStorm for the first time, create a fresh PostgreSQL database.

Connection String

The only complicated configuration required in the CopyStorm Main tab is the PostgreSQL connection string. Clicking on the Connection String Builder button will open a form that will construct the connection string for you, given database information.

The general form of a PostgreSQL connection string is:

  • [//host[:port]][/database-name]

Example:

  • //localhost/CopystormBackupDatabase

By default, a PostgreSQL connection will use the public schema. This can be overridden by entering a schema name.

The following is a screen shot of a working PostgreSQL setup on one of our test computers:

Configuration Tab

The Configuration Tab contains options to modify the CopyStorm runtime, including the list of Salesforce Objects/Tables to copy.

The default view of the Configuration Tab contains core configuration options that are commonly modified.

To view additional options, change the “Configuration Level” dropdown:

  • Standard

    • Core CopyStorm configuration and performance tuning.

    • Options used to ensure that CopyStorm does not interfere with other operations (e.g. limiting Salesforce API Call consumption).

  • Advanced

    • CopyStorm troubleshooting and logging options.

  • Developer

    • CopyStorm application tuning options, advanced network configurations, and query optimization options.

Guardrails

The Guardrails Tab is used to limit the potential impact of individual CopyStorm runtimes and to ensure that CopyStorm jobs do not interfere with other operations.

Parameter Name
Default Setting
Required
Description

API Call Limit

Blank

No

Limits the maximum number of transactions (queries) to send to Salesforce. This option can help avoid exceeding your organizational limit for transactions per 24-hour period. CopyStorm will stop when this value is exceeded. Usually this parameter is only set for the initial load of the CopyStorm database.

API Threshold

Blank

No

Maximum starting API utilization. When CopyStorm is initializing the data copy, if the current Salesforce API usage is above the provided percentage, the copy job is not started.

Maximum Runtime

Blank

No

The maximum number of minutes CopyStorm will run before gracefully shutting down. Leave this blank to disable the time limit.

Production Database Protection

Checked

No

If Checked, CopyStorm will not allow a production Salesforce database to be overwritten by another Salesforce’s data.

Schema Only Backup

Unchecked

No

If Checked, CopyStorm will back up the Salesforce schema, but Salesforce data will not be included. This option is typically used during Salesforce migrations.

Database Reset

The Database Reset Configuration Editor is used to delete and rebuild portions of the CopyStorm database.

Options within the Database Reset Configuration Editor are only used in specific circumstances and should not be left enabled as part of normal backups.

Parameter Name
Default Setting
Required
Description

Force Truncate

Unchecked

No

If checked, CopyStorm will truncate all data from each table and start the backup of records from scratch.

Force Rebuild

Unchecked

No

If checked, CopyStorm will drop each table and rebuild it from scratch.

Keep Deleted Columns

Unchecked

No

If checked, CopyStorm will retain a column in the target database if it has been dropped in Salesforce. By default CopyStorm will drop a column in the target database if it is dropped in Salesforce.

Refresh Columns on DDL Error

Unchecked

No

If checked, CopyStorm will rebuild and refresh columns if an unrecoverable DDL exception occurs. CopyStorm will create a new column, requery Salesforce for the column's data, and will rename the new column to replace the old column. This toggle is useful when Salesforce field definitions change in such a way that the corresponding Alter Column SQL commands fail.

Rebuild on DDL Errors

Unchecked

No

If checked, CopyStorm will drop and rebuild a table if an ALTER statement on the table causes a DDLexception.

External Configuration

The External Configuration Editor is used to provide external folders used by CopyStorm to read configurations and to store temporary files.

Parameter Name
Default Setting
Required
Description

Config Directory

Blank

No

By default, CopyStorm will look for configuration file overrides in the directory “config” within the CopyStorm installation directory. If this value is set then CopyStorm will also look in this directory for configuration file overrides.

Temp Directory

Blank

No

By default, CopyStorm will store temporary files containing Salesforce Files and Attachments in the default Java temporary directory. If this value is set then CopyStorm will instead store temporary files in the provided directory. Note: If large files are being downloaded from Salesforce, this directory can become many GB in size.

Database Indexing

The Database Indexing Configuration Editor is used to enable or disable automatic database index creation.

Parameter Name
Default Setting
Required
Description

Create Indexes

Checked

No

If checked, CopyStorm will create database indexes for each reference field. Enabling index creation will significantly improve the table join speed in larger databases. Note that an index is always created on each table’s “timestamp” column.

Create Indexes Early

Checked

No

If checked then CopyStorm will create indexes on Salesforce reference fields when a table is initially created. If not checked then reference field indexes will be created after the first backup of a table. This option can avoid a long delay or timeout when indexes are originally created on tables with many rows.

Create IsDeleted Index

Checked

No

If checked then CopyStorm will create an index on the fields (IsDeleted, SystemModstamp).

Rebuild Timestamp Index

Unchecked

No

If checked, the index on the SystemModstamp column will be rebuild if enough new records are inserted. In some database configurations, this can increase performance dramatically.

Advanced Retention Rules

Though every Snapshot Policy has a default record retention rule, it is often convenient to have a custom retention rule for specific tables. Example:

  • By default, retain records in a snapshot for 90 days.

  • Retain Account, Contact, and Opportunity records for 365 days.

  • Retain Case records for 2 years.

  • Do not retain EmailMessage records.

The following two screens illustrate how to set up this policy.

Clicking on the Advanced button launches an editor to override the default record retention rule. The following example sets up the scenario described at the top of this page.

All Changes Filter Rule

The All Changes Filter Rul e always indicates that a record should be snapshot for a change to any field. Basically, if a caller asks if a record should be snapshot then the All Changes Filter Rule will always respond with “Yes.”

This rule is useful for any table where all changes should be included in the snapshot.

Since the All Changes Filter Rule always says “Yes, this record should be snapshot”, naturally its only configuration parameter is which tables to include in the snapshot.

SQL Predicate Filter Rule

A SQL Predicate Filter Rul e is useful when other filtering techniques are insufficient and it is possible to write a database SQL fragment to identify records that match a snapshot policy. It is rare to need this filter rule because filtering can typically be accomplished using the graphical Column Expression Filter Rule.

A SQL Predicate Filter Rule has a single configuration parameter: a fragment of database specific SQL will be added to the WHERE clause of a SQL statement generated by CopyStorm. Example:

  • SELECT Id FROM Account WHERE Id IN (…) AND (configuration parameter from SQL Predicate Filter)

If the argument to a SQL Predicate Filter Rule was “RecordAge__c>46 OR alwaysSnapshot__c=1” then SQL statements generated by CopyStorm would look like:

  • SELECT Id FROM Account WHERE Id IN (…) AND (RecordAge__c>46 OR alwaysSnapshot__c=1)

A SQL Predicate Filter Rule also includes a rule for which tables to include in the snapshot.

Delete Snapshot Policy

Though it is possible to delete a Snapshot Policy, usually a site will simply want to make the policy inactive. When a Snapshot Policy is deleted both the policy definition and all data snapshot by the policy are deleted from the CopyStorm database.

The Snapshot policy deletion tool is launched using right-click context menu on the CopyStorm Snapshot tab.

Run Snapshot Policy Retention Rules

The Run Snapshot Policy Retention Rules feature is used to force a snapshot to look for records that should be deleted from the Snapshot based on its retention rules and then delete the records. This happens automatically for active Snapshot Policies as part of the regular CopyStorm backup process, so this feature is most useful for inactive Snapshot Policies.

The Run Snapshot Policy Retention Rules feature is accessed from the right-click context menu on the CopyStorm Snapshot tab.

There are only two parameter options when running retention rules.

  • Search Batch Size — number of records that will be searched at once for potential deletion.

  • Deletion Batch Size — number of records that will be deleted in a single database transaction.

Refresh Snapshot Statistics

Like most database systems, the CopyStorm Snapshot system will operate most efficiently when its has statistics about what is stored in snapshots. Example:

  • If CopyStorm knows what tables have been snapshot by a policy then it can limit searches to just these tables.

  • If CopyStorm knows how may records are in a snapshot it can generated more efficient SQL queries.

For the most part, CopyStorm Snapshot updates statistics without any user intervention. This page, however, describes how to force CopyStorm Snapshot to update statistics if the most accurate statistics possible are desired or if the statistics have been corrupted. Note: it is unlikely that you will ever need this feature.

The Update Statistic s feature is accessed from the right-click context menu on the CopyStorm Snapshot tab.

In the Refresh Statistics dialog there is the option to refresh statistics for a single snapshot or for all snapshots in the system. The following image illustrates what the screen may look like after refreshing statistics for a single snapshot.

Configuration Files

CopyStorm supports saving a backup configuration to a file in two formats:

  • Plain-text XML.

  • Encrypted text (256-bit DES encryption).

Both formats support the optional saving of Salesforce and database credentials. A CopyStorm backup configuration can be completely restored by going to File/Open in the application menu. To save a configuration, go to File/Save in the application menu:

The plain-text XML version of the file is fairly complex and not intended to be edited by hand, but it is possible. However, Capstorm may not provide support for problems arising from a hand-edited configuration file.

How to Set Database Specific Initialization Options

In certain configurations it may be necessary to run specific SQL statements or set database specific options each time a connection to a database is established.

Oracle

The configuration file “Oracle.xml” contains parameters that control connections made to Oracle. The following configuration directives are supported:

  • InitSQL — specify a line of SQL that will be run each time a new connection to Oracle is established. There is no limit to the number of InitSQL elements.

The following Oracle.xml file will cause CopyStorm to run the command:

  • alter session set ‘_optimizer_rownum_pred_based_fkr’=FALSE

Oracle.xml:

<Oracle>
    <InitSQL sql="alter session set &quot;_optimizer_rownum_pred_based_fkr&quot;=FALSE" />
</Oracle>

How to Change License Servers

If your site does not permit communication with the default Capstorm license server located at https://license.capstorm.com, the configuration file “Capstorm.xml” allows overriding the endpoint.

An example that changes CopyStorm to use a http (non-SSL) endpoint for license management is:

<Capstorm>
    <licenseServer url="https://license.capstorm.com/LicenseStore/GetLicense" />
</Capstorm>

There are a number of other elements that can appear in a Capstorm.xml file, but you should not change without being instructed to by Capstorm. However, if you want to confuse your colleagues you can change CopyStorm’s background color:

<Capstorm>
    <backgroundColor red="255" green="100" blue="15" />
</Capstorm>

How to Solve OPERATION_TOO_LARGE Errors

How to Solve OPERATION_TOO_LARGE Errors

If CopyStorm is reporting an OPERATION_TOO_LARGE error, it will be included in the CopyStorm log. The error will look like this:

09:02:11: [UnexpectedErrorFault [ApiFault exceptionCode=’OPERATION_TOO_LARGE’ exceptionMessage=’exceeded 20000 distinct ids’ extendedErrorDetails='{[0]}’ ] ] Before diving into the root cause, this is the most common solution:

  • Grant the ViewAllData privilege to the Salesforce credentials being used with CopyStorm.

Root Cause

The root cause of this exception can be found in the Salesforce description of the error:

  • OPERATION_TOO_LARGE

The query has returned too many results. If certain queries are run by a user without the “View All Data” permission and many records are returned, the queries require sharing rule checking. For example, consider queries that are run on objects, such as Task, that use a polymorphic foreign key. These queries return this exception because the operation requires too many resources. To correct, add filters to the query to narrow the scope, or use filters such as date ranges to break the query up into a series of smaller queries.

You can find the Salesforce documentation in the Core Data Types section.

Almost all CopyStorm sites will want to use Salesforce credentials with the ViewAllData permission because without this permission all data will not be backed up. In particular, no metadata will be backed up because the API call used to fetch metadata requires the ViewAllData permission.

I Need a Timebox Approach Because ViewAllData is Not Allowed

If your organization does not want to give your CopyStorm backup user the ViewAllData permission and an incomplete backup is OK, you can configure CopyStorm to backup data using a sliding timebox.

For example, to backup the Note table using a 60 day sliding timebox, the following TableRule must be added to your site’s TableRuleRegistry.xml file:

This XML rule means:

  • Use a sliding 60 day window when backing up Note.

  • Start the first search on 1-Jan-2001.

  • Start subsequent searches at the timestamp on the most recent Note record in the backup.

The system will backup Note records in roughly the following order:

1-Jan-2001 thru 28-Feb-2001 1-Mar-2001 thru 30-Apr-2001 1-May-2001 thru 30-Jun-2001 etc… until the current date is reached.

How Does CopyStorm Search for Configuration Files?

There are a number of XML configuration files that can be used to override default CopyStorm behavior. This article describes the approach CopyStorm uses to find configuration files.

When CopyStorm searches for a configuration file, it looks in four places:

  1. Configuration files embedded within the CopyStorm application.

    1. CopyStorm always looks here first.

  2. Configuration files in the “config” subdirectory of the CopyStorm installation.

    1. CopyStorm always looks here.

  3. Configuration files in the directory specified by the Configuration tab “Config Directory” option within the “External Configuration” section.

  4. Configuration files in the directory specified by the “-config” command line argument.

    1. CopyStorm looks here ONLY IF the Advanced tab setting is blank.

If a configuration file is found in multiple locations, all are loaded in the order listed above. Later loaded files will override any configuration from earlier files.

Documentation on available XML configuration files can be found on this page.

Best Practices

Capstorm recommends the following best practices:

  • Keep each CopyStorm configuration file in its own directory OUTSIDE of the CopyStorm installation directory.

    • This will make the CopyStorm upgrade process simpler.

  • If you need custom XML configuration files then:

    • Store them in the same directory as the corresponding .copyStorm configuration file.

    • Set the Configuration tab “Config Directory” parameter in your .copyStorm file to point to the directory where the .copyStorm file is located.

How to Enable Oracle’s EXTENDED Varchar2 Option

Oracle 12c added support for extending the allowed length of VARCHAR2 columns from 4000 to 32,767 bytes but made the discovery of whether this feature is enabled require privileges that a normal Oracle user is not granted. This article explains how to tell CopyStorm that the Oracle feature “max_string_size=EXTENDED” is enabled without requiring special Oracle permissions.

For your reference, if an Oracle user has enough privileges then a simple query can be used to determine if the EXTENDED Varchar2 feature is enabled.

  • SELECT name,value FROM V$PARAMETER WHERE name=’max_string_size’

It is likely that your account will return a “Table or View not Found” when running this query because of your limited permissions.

To inform CopyStorm that the EXTENDED feature is enabled simply create a file named Oracle.xml and drop into the your private CopyStorm configuration directory specified on the Advanced tab or into the directory [CopyStormRootDir]/config. The content of the Oracle.xml file should be:

<Oracle>

<DatabaseProperty name="max_string_size" value="EXTENDED" />

</Oracle>

Restart CopyStorm and future VARCHAR2 columns will be up to 32,764 bytes in length. You may wonder why the limit is 32,764 rather than 32,767. The reason is that Salesforce defaults to a UTF-8 Extended character set and each character can take up to 4 bytes.

How to Override Snowflake staging location

Internally, CopyStorm replicates data to Snowflake by creating a CSV file of the records being backed up and uploading the CSV file to Snowflake. It may be required to change this staging location to meet business requirements. CopyStorm allows customers to specify a different Snowflake stage by following this process:

Create a xml file named “SnowflakeDatabaseBuilder.xml”

Then place the contents below into the xml file.

<SnowflakeDatabaseBuilder>
    <SnowflakeStage value="@clientProvidedStagePath"/>
</SnowflakeDatabaseBuilder>

You will need to replace “clientProvidedStagePath” with the Snowflake stage’s path, then place this file into CopyStorm/config directory and relaunch CopyStorm.

Note: This feature is available in CopyStorm versions 10.56.5 and above.

How to Set Application Initialization Options

Background

Note: This feature is available in Capstorm application versions 10.56.6 and above.

Capstorm applications allows you to add supplementary Java options. These options serve to dynamically alter the operational parameters of the application prior to its initiation. One frequent utilization, which serves as an example throughout this article, is the facilitation of user-driven control over memory allocation for any of Capstorm’s applications. This capability gives users the control to finely calibrate the memory resources dedicated to the operation of Capstorm’s applications.

Configuration File Creation and Placement

Note: Application must be restarted for these configuration files to be applied.

Step 1 – File Creation and initial template setup:

  1. First create a XML file named “AppLoader.xml”

Step 2 – File Placement:

Two recommended placement options:

  • Option 1: If you followed CopyStorm’s Best Practice Directory Structure then we recommend placing this configuration file in CapstormConfig directory.

    • copystorm-directory-structure

  • Option 2: Inside of one of Capstorm’s application installation directory there should be a directory called “config”. You can also place this configuration file in the “config” directory.

How to Customize Application Memory

Note: For versions older than 10.56.6 please visit: out-of-memory-java-heap-space-error on how to configure memory settings.

  • Once you have completed “Configuration File Creation and Placement” steps you can simply copy the snippet below into the AppLoader.xml configuration file.

  • The example below shows how to set the min and max memory allocations to 300 and 1000 megabytes, respectively.

How to Add Custom Java Properties

The AppLoader also allows for custom Java Properties. Below is an example of setting the HTTPS Protocols to TLSv1.1 and TLSv1.2.

How to Change Schema Initialization Options

While commonly used schema options within CopyStorm are directly exposed in the CopyStorm GUI, a number of schema initialization parameters can only be provided by providing CopyStorm with a JDBCDatabaseBuilderConfig.xml file.

To use the options detailed in this page, create a JDBCDatabaseBuilderConfig.xml file and copy it to one of the CopyStorm Configuration File Directories.

Capitalize Column & Table Names

The following XML will cause CopyStorm to create a Salesforce data table and column names in ALL CAPS.

<JDBCDatabaseBuilder>
<!-- 
    Set these values to "true" to capitalize table and column names.
-->
	<CapitalizeTableNames enabled="true" />
	<CapitalizeColumnNames enabled="true" />

</JDBCDatabaseBuilder>

Remove Table & Column Postfixes

The following XML will cause CopyStorm to remove Salesforce-standard postfixes from database table and column names.

Log Manager

The CopyStorm/Medic Log Manager tool supports the viewing, management, and exporting of the results of previously run CopyStorm jobs.

Starting with version 7.*.*, CopyStorm stores the status of each job into tables in the CopyStorm target database. The CopyStorm/Medic Log Manager is a convenient tool for viewing, managing, and exporting the contents of these tables. In addition to Log Manager, regular RDBMS tools can be used to access CopyStorm’s logs.

Full documentation for the CopyStorm/Medic Log Manager tool can be found here.

The database tables used for RDBMS access to CopyStorm and CopyStorm/Medic logs can be found here.

Delete Salesforce Records in Batch Mode

The CopyStorm/Medic Delete Salesforce Records tool has the ability to run batch mode without the need of opening the application GUI and click through the steps of the tool. Execution of the tool in this manner requires a CopyStorm/Medic configuration file that already has all desired configuration options and filters selected and saved. For more information regarding the setup of this tool, see here.

When executing the Delete Salesforce Records tool through the CopyStorm/Medic GUI, there is a security pop-up that requires users to type the name of the target Salesforce org before beginning the deletion process. This security feature does NOT occur when executing in batch mode.

Example Usage

This example is for Windows installations of CopyStorm/Medic. For Linux/Mac installations, change CopyStormMedic.bat to CopyStormMedic.sh

CopyStormMedic.bat -tool deleteTool -run "/path/to/config.copyStormMedic"

How do CopyStorm Partitions Work?

When replicating Salesforce data and schema to the CopyStorm database, CopyStorm will create database tables and columns which mirror the object and field structure in Salesforce. For example, there is a Salesforce object called “Account”, with a String field called “Name”. This means that the CopyStorm database will have a table called “Account” with a VARCHAR or CLOB field called “Name”.

CopyStorm partitions use a technique called Vertical Partitioning to change the CopyStorm database schema by separating the database table for an object into multiple tables. Of course – CopyStorm, CopyStorm/Restore, and CopyStorm/Medic are fully compatible with CopyStorm partitions.

For example, by default, the CopyStorm database may have an “Account” table with these columns:

  1. Id

  2. SystemModstamp

  3. Name

  4. BillingStreet

  5. BillingCity

  6. BillingState

If the “Billing” fields are moved to a new partition, the database will have multiple tables:

  1. The “Account” table, with these columns:

    1. Id

    2. SystemModstamp

    3. Name

  2. An “Account__part1” table, with these columns:

    1. Id

    2. BillingStreet

    3. BillingCity

    4. BillingState

Virtually any field can be moved to a partition if needed – with the exception of a small number of fields that require special handling.

  • The “Id” database column is always present on every partition.

  • A handful of fields are required to remain on the primary partition:

    • IsDeleted

    • Salesforce Modification Timestamps:

      • SystemModstamp

      • LastModifiedDate

    • Salesforce Audit Timestamps:

      • CreatedDate

      • LoginTime

      • SentDate

  • Fields that are encrypted with the CS:Govern application.

Partitions may be created for virtually any object – the only exceptions are:

  • BigObjects

  • Tables that are included in the CopyStorm Database View system.

Permission Checker

The CopyStorm/Medic Permission Checker will find Salesforce tables and fields that are visible using the Salesforce metadata API but are not visible for backup using the current Salesforce credentials.

It is a common misconception that a member of the Salesforce Administrator group can see all table and fields in a Salesforce instance. In practice, there are even many standard Salesforce fields that a Salesforce Administrator cannot view by default. The Permission Checker helps you find these tables and fields.

Running the Permission Checker in a GUI

Running the Permission Checker involves clicking on a single button – Start Scanning Metadata.

  • The Salesforce user credentials provided to the Permissions Checker must have access to read the Salesforce metadata definitions for each object.

  • Use of the metadata API requires the system permission “Modify Metadata Through Metadata API Functions.”

Do not be alarmed when you find a lot of fields that are not visible to a Salesforce Administrator. Most likely you are not using them in your instance.

Running Permission Checker as a Batch Job

The Permission Checker tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool findPermissionErrors -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool findPermissionErrors -run configFile.copyStormMedic

S3 Partition Configuration

To configure a S3 partition in CopyStorm/Medic, provide connection information for the target S3 bucket.

CopyStorm will use the AWS Default Credential Provider Chain to connect to S3. Environment variables, Java Properties, IAM Roles, etc… can be used to authorize CopyStorm for S3 access.

To initialize the partition, CopyStorm/Medic will:

  • Copy field data for the selected fields into the target bucket, using the folder name as a prefix.

  • DROP the database storage used by the selected fields.

When CopyStorm replicates new or updated records, field values for the selected fields will be kept in files in the target bucket.

Record data is kept in a nested structure generated using Salesforce Ids.

Snapshot Tab

The CopyStorm Snapshot tab is the launch point for creating, editing, using, and exploring CopyStorm snapshot data sources. A CopyStorm Snapshot is a database store containing tamper-proof snapshots of records from any Salesforce table where the snap-shots are taken based upon rules specified by a user.

CopyStorm Snapshots can be used to store many types of data.

  • A Snapshot can be used to create a unlimited duration recycle bin or a recycle bin where data retention policies vary by table.

  • A Snapshot can be used to permanently save a copy of Salesforce records on demand.

  • A Snapshot can be used to track all versions of critical Salesforce records.

Each CopyStorm Snapshot has policies which determine which table and which records should be snapshot. Like the core CopyStorm backup process, Snapshot policies can be applied automatically as a regular part of a backup or can be applied on demand.

The CopyStorm Snapshot GUI

The CopyStorm Snapshot tab lists all currently defined snapshots, can be used to create a new snapshot, and is the launch point for most Snapshot operations including:

  • Edit a Snapshot Policy’s Rules

  • Explore the data in a Snapshot

  • Delete a Snapshot Policy and its data

  • Run a Snapshot Policy on demand.

  • Apply a Snapshot Policy’s data retention rules.

Next Steps

To get started with CopyStorm Snapshots, please review the following:

  • CopyStorm Snapshot System Overview

Once you have the basics down try one of these tutorials:

  • How to Setup the Capstorm Recycle Bin

  • How to Setup a Custom Snapshot Policy

  • How to Explore and Export Snapshot Data

Finally, jump to any of the following reference articles:

  • Snapshot Policy Editor

  • Refresh Snapshot Statistics

  • Run a Snapshot Policy

  • Delete a Snapshot Policy

  • Snapshot Explorer

Policy Filter Rules

A Snapshot Policy Filter Rule contains the logic which determines if a database record should be processed by the snapshot policy. There are several types of policy filters built into CopyStorm Snapshot.

  • All Changes — this filter always indicates that a record should be processed. Use it when all changes to records should be snapshot.

  • Column Expression — with this filter a rich expression based on columns in a record can be used to determine if a record should be snapshot.

  • Deleted Records — this filter only matches records that have been deleted in Salesforce. This filter is used to build recycle bin type policies.

  • SQL Predicate — this advanced filter supports injecting user specific SQL fragments into a query that determines if a record should be snapshot.

The Filter Rule for a Snapshot Policy is specified on the Main Tab of the snapshot editor.

Parameters specific to the selected Filter Rule Type can be set on the Filter Rule Parameters tab.

White and Black Lists

Nearly all Filter Rule Types support the concept of a White and/or Black list for selecting the tables to be processed by the policy.

  • A White List indicates tables to include in the snapshot.

  • A Black List indicates tables to exclude from the snapshot. All tables not on the black list will be included.

Typically the technique used for selecting tables for a snapshot is either by White List or Black List. However, if you are brave (and using regular expressions) both a White and Black list may be useful.

The following example (from the All Changes filter rule type) illustrate the components of the White/Black list editor.

  • The pull-down menu indicates whether tables should be selected by White list, Black list, or both.

The dialog for selecting tables is nearly the same for a White or Black list. The following example is for a White list.

Explore Snapshot

The Snapshot Explorer is a tool for viewing and exporting data from a CopyStorm Snapshot. The tool is launched from the CopyStorm Snapshot tab.

The Snapshot Explorer has four stages, indicated by the navigation bar at the top of the dialog.

  • Start — Select the snapshot to explore.

  • Select Table — Select a table from the Snapshot to explore.

  • Preview — Build a query and preview the selected data from the Snapshot.

  • Export — Export the data from the snapshot in a variety of formats.

Start Stage

Select Table Stage

In the Select Table stage, select the table you wish to explore and optionally select the columns in the table to view. Note that you can always return to this stage in order to update the selected columns.

Preview Stage

In the Preview Stage, optionally create a filter that limits the records to view or export. The filter is created by dragging and dropping elements from the left hand side of the screen to the big white box on the right.

In the example screen shot a filter for finding records with a capstorm email domain has been specified and then the Refresh Preview button was clicked.

Export Stage

In the Export Stage:

  • Review and update the list of columns to export.

  • Click on the Start Snapshot Export button and the system will display a typical Save As dialog.

By default, only the most recent version of a record will be written in the export. To override this behavior and write ALL VERSIONS of a record to the export check the box to Include All Snapshot Record Versions of a Salesforce Record. Of course, even if this option is checked, a record still has to pass the filter criteria from the Preview stage.

The Save As dialog which appears after clicking on Start Snapshot Export will look like your system’s default dialog with the addition of a file format selection section.

When the result of an export is loaded into your favorite spreadsheet it will look like:

Run Snapshot Policy

The Run Snapshot Policy feature is used to run a snapshot policy against existing data in a CopyStorm snapshot on demand. This process is useful in a number of circumstances.

  • Suppose a new snapshot for all Cases older than 2 years was just defined. Before activating the snapshot policy (so it will run automatically when a backup happens) you may want to snapshot all existing cases in the CopyStorm database that are older than 2 years.

  • Your compliance department has told you to snapshot all records related to ACME, Inc. because they have filed a breach lawsuit against the company. In this case the snapshot policy that you define may run just once — on demand — and never be scheduled to run automatically.

The Run Snapshot Policy feature is accessed from the right-click context menu on the CopyStorm Snapshot tab.

There are just a few options to run a Snapshot Policy by hand.

  • Scan Records From sets a start date from which records will be searched. By default the start date will be the date of the earliest record in the corresponding CopyStorm table.

  • Scan Records Thru sets the last date on which records will be searched. By default the end data will be the most recent date in the CopyStorm database.

  • # Concurrent Searches limits the number of tables that will be processed concurrently. You can set it to a large value (like 200) but be aware that a large number will consume considerable database resources.

  • # Searches Per Batch limits the number of records that will be evaluated by the snapshot policy concurrently (on a per table basis). A larger number will increase performance slightly at the cost of making the user interface a bit less responsive.

  • # Snapshot Per Batch limits the number of records that will be written to a snapshot in a single database transaction.

While a Snapshot Policy is running the screen will continuously update with progress information. At any point in time you can cancel the snapshot process and only records snapshot so far will be preserved in the database.

The following screenshot illustrates how the dialog will appear after a snapshot policy has run to completion. Note that are several reasons that a record may be processed but not snapshot.

  • If a record fails to match the filter associated with the snapshot policy then it will be skipped.

  • If a record matches the filter associated with the snapshot policy but is already in the snapshot with exactly the same data then it will be skipped.

Batch File Tab

The Batch File tab is used to generate a script that can be used to launch CopyStorm as a batch job. Generated scripts encapsulate everything needed to run a CopyStorm job, including:

  • The location of CopyStorm.

  • The location of the configuration file defining backup parameters.

For many sites a generated batch file is not necessary due to built-in command line options in the main CopyStorm launch script allowing batch mode execution. Example command lines include:

  • sh CopyStorm.sh -run /path/to/my/configFile.copyStorm

  • CopyStorm.bat -run C:\path\to\my\configFile.copyStorm

The Core Tool

The core function of the Batch File tab is to generate a script file that will:

  • Run CopyStorm using a specific configuration file from any directory using just the name of the script file.

  • Capture any exception information from CopyStorm to “do something” with the data. By default the script emails exception information to a user but this can easily be adapted to other purposes.

If you have configured the Notifications tab, the process for generating a script file is simple. This is the approach used nearly 100% of the time:

  • Use the “Script Format” menu to specify the desired scripting language — bash, bat, python, or vbs.

  • Click on the “Generate Script” button.

  • Click on the “Save Script” button and save the script to a file.

If your site cannot use the built-in Notification system the process for generating a script file is:

  • Use the “Script Format” menu to select one of the script formats marked as Advanced.

  • Enter an email address for the notification sent each time the script runs.

  • Enter an email address for the notification sent if CopyStorm reports an exception.

  • Enter the name of your local SMTP server.

    • In the example a public server hosted by Google is used.

  • Enter the email address that will send the email.

  • Click on the “Generate Script” button.

  • Click on the “Save Script” button and save the script to a file.

  • Edit the generated script’s code to implement your custom notification requirements.

After these steps are completed, you own the generated script file and can change it in any way you prefer.

If you have trouble getting the email portion to work properly, please read this FAQ.

Snowflake Connection

Initial Steps

Before running CopyStorm for the first time, create a dedicated Snowflake database for your Salesforce data.

Connection String

Compared to the other Database types, Snowflake’s connection string is more complex and carries more information. For this reason, it is recommended to use the Connection String Builder to create a valid Connection String.

Connection String Builder

After clicking on the “Connection String Builder” button, a dialog menu will open, as seen below.

Parameter
Description

Server Name

The IP Address, URL, or server name of the snowflake instance. Port number is optional.

Database Name

The name of the Snowflake database that CopyStorm will populate with Salesforce data.

Private Key File

The file path to the Snowflake Private key. For more information on Private Keys and Snowflake’s key-pair authentication, refer to Snowflake Documentation.

Key File Password

If your Private key was configured to require a password for use in authentication, enter it here. If your Snowflake Private key was configured as to not require a password, this field can be left blank.

Warehouse (optional)

The name of a Warehouse in Snowflake that you wish to use. For more information on Snowflake Warehouses, refer to Snowflake Documentation.

Proxy Host (optional)

The IP address, or URL of a proxy used to connect to a Snowflake instance.

Proxy Port (optional)

The port number associated with a proxy used to connect to a Snowflake instance.

Proxy User (optional)

The username to authenticate a request with a proxy used to connect to a Snowflake instance.

Proxy Password (optional)

The password used to authenticate a request to a proxy used to connect to a Snowflake instance

Proxy Protocol (optional)

The protocol by which a connection will be made to a proxy used to connect to a Snowflake instance. Select either HTTP, or HTTPS.

Field History

The Field History Configuration editor is used to enable and configure CopyStorm field history tracking.

CopyStorm field history tracking supports the tracking of nearly all field changes in every Salesforce object.

If the “Track Field History” checkbox is selected, the default behavior is to track all changes to all fields. To limit field history tracking or to customize retention periods for field history changes, click on the “Edit” button for advanced Field History configuration.

Field history changes are kept in a database table named “CopyForceFieldHistory”. For details see:

  • CopyStorm Logging Tables

Field History Editor

Field History is controlled by three major elements:

  • Whitelist — A Whitelist controls which tables (and optionally fields) participate in field history. An unlimited # of white lists can be defined.

  • Blacklist — A Blacklist controls which tables DO NOT participate in field history

  • Retention Days — Retention Days controls how many days CopyStorm should keep field history. This can be control on a per table basis and can range from 1 day to forever.

To setup Field History rules there are several decisions to make:

  • Do I want to control what tables are backed up using a Whitelist or Blacklist approach?

  • By default, how many days should field history records age before they are automatically deleted by CopyStorm?

  • Are there any tables whose field history records I want to keep longer (or shorter) than the default?

The Field History Editor has several major components:

  • Global Parameters specify constraints applied to all rules.

  • The Whitelist/Blacklist editor indicates which tables should (or should not) participate in field history tracking.

Global Parameters

There are several global field history parameters.

  • Include Formula Columns parameter controls where changes to formula fields are recorded as field history changes. The default is false.

  • The Exclude Audit Fields parameter restricts common Salesforce auditing fields from being records in field history. There are several reasons to exclude an audit field.

    • A field is a timestamp field that changes on every record change.

    • A field is Salesforce maintained formula field (example: LastViewedDate)

    • A field is also recorded as separate column in CopyStorm’s field history table.

To change the list of excluded audit fields click on the Edit… link the left of the field label.

Whitelist/Blacklist Editor

The Whitelist/Blacklist part of the editor is used to manage what tables participate in field history tracking.

  • The Whitelist indicates what tables should participate in field history tracking. If the whitelist is empty this means that all tables except those in the blacklists will be tracked.

  • The Blacklist indicates what tables should not participate in field history tracking.

Of course, in practice either the whitelist or blacklist is used but not both. When the white list is not empty the blacklist is effectively ignored.

Before configuration the editor looks like:

Select specific tables and/or table patterns to add to the white list by clicking on the appropriate button.

If the default field retention rule is too short (or long) for specific tables, an extra white can be added to change the retention rule. The example below changes the retention rule for Account and Contact to 1000 days.

Limit Fields Subject to Tracking

It is possible to limit the fields tracked for a specific table by edit the table’s rule. Of course, doing this means that any new fields added to a table will not be tracked by default.

The following image illustrates how to limit the fields tracked for the Account table.

Database Networking

The Database Networking Configuration Editor contains networking and SQL parameters used when communicating with the CopyStorm database.

Parameter Name
Default Setting
Required
Description

Destination Batch Size

100

No

Limits the number of rows that will be written to the target database in a single batch. A smaller number minimizes memory requirements but increases run time. A larger value increases memory requirements and decreases run time.

DDL Timeout (seconds)

Blank

No

Set the number of seconds CopyStorm will wait for a DDL operation to complete. DDL operations, like CREATE INDEX, may take considerably longer than DML operations and thus have their own timeout parameter.

# Database Buffers

10

No

Sets the number of output buffers to use when running in multi-thread mode. A larger value increases memory requirements but allows Salesforce to read more records before they are written to the target database.

Rows Per Multi-Insert

Blank

No

If specified then multiple rows will be sent to the database in a single INSERT statement. Please note that not all databases support this feature and when the database is on a local network there is unlikely to be any performance gain by enabling this feature.

Enable CSV Bulk Import

Checked

No

If set and is supported by the database then CSV bulk imports will be used. For analytical databases like RedShift or Snowflake this option should almost always be selected.

Database Optimization

The Database Query Optimization Parameter Editor controls optimizations used when generating SQL queries for the CopyStorm database.

Parameter Name
Default Setting
Description

Optimize Insert SQL

Unchecked

If checked, CopyStorm will not include NULL data in generated INSERT statements. For wide tables with many NULL values this may be considerably faster than unoptimized INSERT statements.

Optimize Update SQL

Checked

If checked, CopyStorm will compare data from Salesforce with existing data in the CopyStorm database and build minimal SQL UPDATE statements. For wide tables with few changes this may be considerably faster than unoptimized UPDATE statements.

Optimize Timestamps

Checked

If checked, then use the time of the most recently complete CopyStorm job to reduce the number of records read from Salesforce. If not checked, then the timestamp of the newest record in Salesforce is used to build SOQL queries, and at least one record from each table will always be read.

Force Updates

Unchecked

If checked, CopyStorm will write all records read from Salesforce to the target database. Records will be updated even if the timestamp is the same as the Salesforce timestamp. This option can be used in conjunction with the “Modified Since” and “Modified Thru” parameters to force CopyStorm to re-read records from Salesforce and update any fields that are out of sync.

Optimize Deleted Record Scan

Checked

If checked then CopyStorm will use information from the previous backup to minimize the number of records scanned when searching for deleted records. This option is ignored if the Delete Older Than option is blank.

Update Using DELETE/INSERT

Unchecked

If checked then CopyStorm will UPDATE records by first deleting them and the re-inserting them. This option is ignored if the Optimize Update SQL option is checked.

Optimize Update Classification

Checked

If checked, CopyStorm will try to avoid database queries used for deciding if records are inserts or updates. If this parameter is unchecked, CopyStorm will always query the database to decide if a record should be inserted or if a pre-existing record should be updated in the database. For example, if a table is empty when CopyStorm starts to copy data, then there is no reason to look for updates - all records will always be inserts.

Optimize Snapshot Purge

Checked

When checked, Snapshot record cleanup will happen after all records are copied from Salesforce. When unchecked, Snapshot records will be cleaned up after each object is replicated.

Salesforce Network

The Salesforce Network Configuration Editor contains networking and SQL parameters used when communicating with Salesforce.

Parameter Name
Default Setting
Required
Description

# Reconnect Attempts

5

No

The number of times to try to automatically reconnect with Salesforce if the connection to Salesforce has dropped.

Reconnect Delay

15

No

The number of seconds to wait between attempts to reconnect to Salesforce.

Backup Rich Text Images

Checked

No

If checked then CopyStorm will replicate images embedded in Salesforce Rich Text fields and Knowledge Articles. Images are stored in the tables CopyForceRtImage and CopyForceImageData.

Backup URL Images

Checked

No

If checked then CopyStorm will replicate images linked to in URL Image fields. Images are stored in the tables CopyForceURLImage and CopyForceImageData.

Ignore Numeric Overflow

Checked

No

If checked, then if a numeric formula column contains a value which would cause a numeric overflow in the database then the database value will be set to null. The most common cause of this issue is an ill-defined Salesforce formula column with a near divide by zero error.

Max Base64 Reader Threads

Blank

No

Set the maximum number of base64 values that will be read concurrently when processing tables containing base64 columns using the REST API. This option can greatly increase the rate at which tables like Attachment and ContentVersion are backed up by downloading the raw file content for multiple records concurrently.

Continue On Missing Base64

Blank

No

If checked, then if a Base64 file body cannot be downloaded CopyStorm will report an error and continue replicating additional files. If unchecked, then CopyStorm will halt the replication for a Base64 object when the first unreadable Base64 entry is encountered.

Global Parameters

The CopyStorm/Medic Global Parameters page sets parameters that apply to all CopyStorm/Medic jobs.

The Global Parameters page can be found by selecting the “Other Tools” dropdown in CopyStorm/Medic, and clicking “Global Parameters” in the dropdown list.

Parameter
Description

API Threshold

Do not run CopyStorm/Medic jobs if Salesforce API usage is above the provided percentage when the job is starting. For example, if you enter “50” in this input then CopyStorm/Medic will not run jobs if Salesforce API usage is above 50% of the maximum.

Folder Partition Configuration

To configure a Folder partition in CopyStorm/Medic, provide the target folder:

To initialize the target directory, CopyStorm/Medic will:

  • Copy field data for the selected fields into the target folder.

  • DROP the database storage used by the selected fields.

When CopyStorm replicates new or updated records, field values for the selected fields will be kept in files in the target directory.

Record data is kept in nested folders generated using Salesforce Ids.

Deleted Records Filter Rule

The Deleted Records Filter Rule indicates that a CopyStorm record should be snapshot only when its IsDeleted flag is set to true. The primary use of the filter is to manage the records added to a recycle bin.

Though CopyStorm is initialized with a policy, Default Recycle Bin, that uses this filter rule, a user can added additional snapshot policies based on a Deleted Records Filter Rule if a non-standard recycle bin is desired.

The only configuration for a Deleted Records Filter Rule is which tables to include in the snapshot.

Run Snapshot Policy from Command Line

This page provides details into the command line options for running snapshot policies for CopyStorm in headless mode. This feature was introduced as part of the 10.65.1 GA release of CopyStorm. For more information regarding running snapshot policies, see here.

Overview

The command line functionality mirrors the same options and functionality as seen in the CopyStorm application using the "Run Snapshot Rules Now" option including:

  • Start and end date ranges for records to snapshot

  • Number of concurrent searches (number of objects snapshot in parallel)

  • Search batch size

  • Snapshot per batch

Command Line Switches

Command Line Switch
Explanation
Required
Default

snapshot

The name of the snapshot to run

Yes

N/A

snapshotThreads

The number of objects to snapshot in parallel

No

10

snapshotSearchBatchSize

The read batch size from the database for candidate records

No

1000

snapshotWriteBatchSize

The write batch size to the database for found candidate records

No

1000

snapshotScanRecordsFrom

The date to start scanning records from (i.e. 2020-01-01)

No

Empty

snapshotScanRecordsThru

The date to end scanning records from (i.e. 2025-01-01)

No

Empty

Example Usage

This example is for Windows installations of CopyStorm. For Linux/Mac installations, change CopyStorm.bat to CopyStorm.sh

How to Control Field History Tracking

CopyStorm supports the tracking of nearly all field changes by checking the “Track Field History” box on the Advanced tab. When field history is enabled, default behavior is to track updates to EVERY field in EVERY table except for a handful of Salesforce auditing fields.

If the default behavior captures more data than your organization prefers, this article explains how to limit what is tracked.

Background

Fine control over field tracking is managed by a configuration file named FieldHistoryRecordFactory.xml. The file can be placed in either the “config” subdirectory of the CopyStorm installation or in the directory indicated in the CopyStorm configuration file. The built-in configuration file has rules excluding field tracking for a number of Salesforce audit fields and all formula columns.

It looks like:

If you create your own configuration file, model it after the built-in file without repeating any of the built-in rules.

Like CopyStorm table selection, there are two basic approaches to controlling which fields are tracked:

  • Telling CopyStorm which fields should be tracked.

  • Telling CopyStorm which fields should NOT be tracked.

If CopyStorm is told which fields to track the rules indicating which fields should NOT be tracked are ignored and only fields CopyStorm is explicitly told to track will be included.

Include Specific Tables

To only track field history on specific tables, include the IncludeTable configuration directive.

The following FieldHistoryRecordFactory.xml will limit field history to the Account, Contact, and MyCustomObject__c tables:

Exclude Specific Tables

To track fields in all tables EXCEPT for a few then use the ExcludeTable configuration directive.

The following FieldHistoryRecordFactory.xml will exclude ApexPages, ApexTriggers, and MyCustomObject__c from field history tracking:

Include Specific Fields in a Table

The following FieldHistoryRecordFactory.xml will cause CopyStorm to only track the “Name” field on “Account” and the “FirstName”/”LastName” fields on “Contact”:

Exclude Specific Fields in a Table

The following FieldHistoryRecordFactory.xml will cause CopyStorm to not track the “WebSite” field on “Account”, and to not track the “Age”/”Birthday” fields on “Contact”:

Track Formula Value Changes

Default CopyStorm behavior is to not track changes to formula column values. The following FieldHistoryRecordFactory.xml will enable formula value history tracking:

How to Fix Incorrect String Value Errors for MySQL

Though MySQL claims support for all UTF-8 characters, experience indicates that not all MySQL variants support the full extended 4 byte UTF-8 character set. When MySQL fails to recognize an extended UTF-8 character and error like this will be displayed:

  • java.sql.BatchUpdateException: Incorrect string value: ‘\xF0\x9F\x98\x8A’ for column ‘CommentBody’ at row 48

To get around this issue, you can configure CopyStorm to replace unsupported 4 byte UTF-8 characters with a substitution.

Note: The extended 4 byte UTF-8 character set contains like 100 variations of a smiley face, trees, hamburgers, etc…

How to Define Character Mappings

Character mappings are defined in a “UTF8Tool.xml” configuration file that can be placed in either the “config” subdirectory of the CopyStorm installation or in a custom config directory you have created. The following UTF8Tool.xml will cause CopyStorm to replace the 4 byte UTF-8 characters for two smiley faces to be converted to their more old fashioned counterparts:

This rule will cause any text containing the specified smiley face characters to have the characters be replaced by “:)” or “:(” before data is written to the database.

How to Convert Hex Strings to UTF Characters

Since MySQL reports UTF-8 problems using a hex byte sequence, you will need a way to convert hex byte sequences to a character suitable for XML. Capstorm has used the tool located at:

  • http://www.endmemo.com/unicode/unicodeconverter.php

To use the tool enter the hex digits from MySQL into the box labeled “UTF-8 Code” (e.g. 20 E2 88 9A) and press the Convert button. Copy the generated unicode character into the “from” parameter in UTF8Tool.xml. Note that you can use the regular UTF-8 character in the “from” parameter rather than the decimal or hex representation.

<TableRule name="Note"  timestamp="LastModifiedDate" timebox="60" timeboxEpoch="2001-01-01" />
<AppLoader>
	<JavaArgument arg="-Xms300m" />
	<JavaArgument arg="-Xmx1000m" />
</AppLoader>
<AppLoader>
	<SystemProperty name="https.protocols" value="TLSv1.1,TLSv1.2" />
</AppLoader>
<JDBCDatabaseBuilder>
<!--  
    Remove the following postfixes from Salesforce data tables and columns
-->
	<RemovePostFixFromTableName postfix="__c,__ka,__kav,__b,__x" />
	<RemovePostFixFromColumnName postfix="__c" />
</JDBCDatabaseBuilder>
./CopyStorm.bat -snapshot "Default Point In Time" "/path/to/config.copyStorm" -snapshotThreads 5 -snapshotSearchBatchSize 5000 -snapshotWriteBatchSize 5000 -snapshotScanRecordsFrom "2020-01-01" -snapshotScanRecordsThru "2025-01-01"
<FieldHistoryRecordFactory>

    <IncludeFormulas status="false" />

    <ExcludeField field="SystemModStamp" />
    <ExcludeField field="LastModifiedDate" />
    <ExcludeField field="LastModifiedById" />
    <ExcludeField field="CreatedDate" />
    <ExcludeField field="CreatedById" />
    <ExcludeField field="LoginTime" />
    <ExcludeField field="LastViewedDate" />
    <ExcludeField field="LastReferencedDate" />

</FieldHistoryRecordFactory>
<FieldHistoryRecordFactory>
    <IncludeTable table="Account" />
    <IncludeTable table="Contact" />
    <IncludeTable table="MyCustomObject__c" />
</FieldHistoryRecordFactory>
<FieldHistoryRecordFactory>
    <ExcludeTable table="ApexPages" />
    <ExcludeTable table="ApexTriggers" />
    <ExcludeTable table="MyCustomObject__c" />
</FieldHistoryRecordFactory>
<FieldHistoryRecordFactory>
    <IncludeField table="Account" field="Name" />
    <IncludeField table="Contact" field="FirstName" />
    <IncludeField table="Contact" field="LastName" />
</FieldHistoryRecordFactory>
<FieldHistoryRecordFactory>
    <ExcludeField table="Account" field="WebSite" />
    <ExcludeField table="Contact" field="Age" />
    <ExcludeField table="Contact" field="Birthday" />
</FieldHistoryRecordFactory>
<FieldHistoryRecordFactory>
    <IncludeFormulas status="true" />
</FieldHistoryRecordFactory>
<UTF8Tool>
    <Map from="&#128522;" to=":)" /> <!-- Smiley face -->
    <Map from="&#128530" to=":(" /> <!-- Frowning face -->
</UTF8Tool>

Salesforce API

The Salesforce API Configuration Editor is used to choose which Salesforce API will be used to copy data.

Data API Options

The Data API Options section is used to configure the primary Salesforce API that will be used to copy data.

  • Salesforce Threads

    • The number of Salesforce Objects that will be backed up at the same time by CopyStorm.

    • The default number is 3, allowable values are 1 – 20. For maximum performance, the optimal value for this parameter is typically 10.

  • Salesforce API

    • The default API to use when querying Salesforce. The default API is REST.

    • Note that CopyStorm will, by default, use REST of any table containing a BASE64 column because this minimizes memory usage for most databases. Common BASE64 tables include Attachment and ContentVersion.

Bulk API Options

The Bulk API parameters section controls when CopyStorm will use the Salesforce Bulk API rather than the default API.

Note that:

  • A Salesforce organization has a limited number of Bulk API calls per 24 hour rolling period. Be aware of your limit.

  • The SOAP or REST API will almost always perform better than the Bulk API if performance is measured in the amount of time a user has to wait for a backup to complete.

    • We suspect that this is because Bulk API queries run on a reduced priority thread within the Salesforce infrastructure.

Parameter Name
Default Setting
Required
Description

Bulk Threshold

Yes

CopyStorm will only use the Bulk API if the number of records read for a table exceeds the “Bulk Threshold” parameter. If this parameter is left blank then CopyStorm will not use the Bulk API. Examples:

  • If set to 0 then CopyStorm will always use the Bulk API (when possible — not all tables are supported by the Bulk API).

  • If set to 50000 then CopyStorm will switch to the Bulk API after 50,000 records have been processed for a table.

To reserve Bulk API calls for tables where it may help, Capstorm recommends setting this parameter to 50,000 or above.

Metadata API Options

The Metadata Data API Options section is used to configure the primary Salesforce API that will be used to copy Metadata.

  • Metadata Threads

    • The number of Salesforce Metadata Types that will be backed up at the same time by CopyStorm.

    • The default number is 5, allowable values are 1 – 10. For maximum performance, the optimal value for this parameter is typically 5.

Maintenance

The Maintenance Configuration Editor is used when troubleshooting replication issues.

Parameter Name
Default Setting
Required
Description

Modified Since

Blank

No

If a date is specified, then only records created or modified on or after the specified date are copied. Built in relative dates are available from a pull-down menu or a fixed date can be entered. When entering a date, the interface will have a yellow background which clears when a date is recognized.

Fixed date formats are:

  • dd-MMM-yy (19-May-1984)

  • M/d/y (5/19/84)

  • dd.MM.yy (19.5.1984)

Modified Thru

Blank

No

If a date is specified, only records created on or modified up to or on the specified date are copied. See format notes above.

Ignore Timestamps

Unchecked

No

If checked, CopyStorm will retrieve records in ID order rather than timestamp order.

WARNING: unless a CopyStorm job runs to completion without errors, using this option will make subsequent incremental updates fail to fetch the proper records.

Analyze UNKNOWN_EXCEPTION

Unchecked

No

When Salesforce returns an UNKNOWN_EXCEPTION this generally indicates that a SOQL query failed in a way the Salesforce infrastructure did not expect. When this option is checked and CopyStorm is running in GUI mode, CopyStorm will do a rather expensive analysis of the failed SOQL and attempt to determine a very small SOQL statement which exhibits the problem. The very small SOQL statement is what Salesforce support will require (even demand!).

Salesforce Optimization

The SOQL Query Optimization Parameter Editor controls optimizations used when generating SOQL queries for Salesforce.

Parameter Name
Default Setting
Required
Description

Estimate Total Time

Unchecked

No

If checked and CopyStorm is running with a GUI, an extra SELECT query will be issued for each table to determine the total number of records to be copied.

SFDC Commit Latency

Blank

No

The number of seconds a Salesforce records has to be unchanged until it can be trusted that records have been written to Salesforce in timestamp order. This is a workaround for Salesforce’s belief in time travel — a record with a timestamp of 12 noon can be written to Salesforce before one with a timestamp of 11:59 am.

Timestamp Latency

900

No

The number of seconds to re-query based on the maximum timestamp from the previous CopyStorm job. This parameter is used to capture record changes that may occur out-of-order based on Salesforce record save behavior – i.e. changes that happen after SystemModstamp values are assigned, but before the record is committed. For more details on Salesforce’s record save behavior see .

Row LIMIT per Query

Blank

No

The default number of records to read from Salesforce with a single SOQL statement. A larger number may reduce the number of Salesforce API calls slightly but also may result in query time outs that CopyStorm must recover from using additional API calls. The default value is 20000.

Always Validate SOQL

Unchecked

No

If checked then CopyStorm will validate every generated SOQL statement to insure that a QUERY_TOO_COMPLEX error is not generated. Since CopyStorm dynamically recognizes QUERY_TOO_COMPLEX errors and rewrites queries to avoid them there is little need for this parameter to be set unless the user is a CAPSTORM developer.

Find Optimal SOQL

Unchecked

No

If check then CopyStorm will take extra effort to generate to optimal load balanced SOQL statements when multiple SOQL statement are needed to read a single row from a table. This parameter is for CAPSTORM developers.

Max Simple Query

Blank

No

The smallest SOQL query that CopyStorm will assume never will generate a QUERY_TOO_COMPLEX error. This parameter is for CAPSTORM developers.

Enable SOQL Query Lookahead

Checked

No

When checked, CopyStorm will read the next batch of record for a table while processing the current batch. This improves the overall performance of CopyStorm with a slightly larger load on the local computer.

Validate SOQL End of Data

Checked

No

If checked then CopyStorm will verify that the backup of a table is complete by running a single validation query. This is necessary in cases where SOQL returns no records from a query when there are records available.

Column Expression Filter Rule

A Column Expression Filter Rule is a rich graphical tool for specifying the conditions under which a record should be added to a CopyStorm snapshot. The interface is patterned after the Salesforce Report Writer expression builder and should feel familiar to most users.

The first step, after selecting the Column Expression option from the Filter Rule Type pull-down, is to launch the column expression filter editor.

Clicking on the Edit Column Expression Filter button will launch the editor.

The following example creates a filter that finds records where:

  • the Name field contains “Louis”

The screen image shows the dialog after the Refresh Preview button has been clicked. Notice that the searched database has multiple accounts with the similar names that matched the filter.

After saving changes and returning to the policy editor, a summary of the filter will be shown. To change the filter simply click on the Edit Column Expression Rule again.

Common Issues

Issue 1: Very few columns are available for selection

The list of available columns is determined as the intersection of all columns from table names matched by the policy’s Include Tables list. If you see a single column named Id then the policy is including all tables in Salesforce and the only common column name is Id. To increase the number of available columns return to the policy editor page and adjust the list of included tables.

Issue 2: No Records appear when I click the Refresh Preview button.

This issue only occurs when there are no matching records in the CopyStorm database in any of the selected tables. The solution is to modify the query.

Fix IsDeleted

The CopyStorm/Medic Fix IsDeleted tool identifies records that have been deleted in Salesforce, removed from the Salesforce recycle bin, but not marked as deleted in CopyStorm.

This situation occurs when:

  • A user deletes records in Salesforce and empties the recycle bin BEFORE CopyStorm has run.

  • A system administrator empties the global recycle bin.

  • A Salesforce API program does a hard delete on Salesforce records. A hard delete bypasses the Salesforce recycle bin mechanism.

Under normal circumstances, when a user deletes a record in Salesforce the record is not really deleted immediately. Instead, it is placed in the Salesforce recycle bin. The mechanism used by Salesforce is a hidden field named “isDeleted”. When CopyStorm runs it copies all modified records — including those where the “isDeleted” flag is set to true. After records are copied by CopyStorm, they are optionally deleted in the CopyStorm database based on parameters set on the Advanced tab.

If normal Salesforce accounts are not permitted to empty their recycle bin (a good practice) then the condition that needs this tool will likely not occur.

Running Fix IsDeleted in a GUI

The UI for the Fix IsDeleted tool contains three parts:

  • The side of the dialog is used to select the tables to scan.

  • The top part of the dialog has parameters that determine if problem records should be fixed.

  • The lower part of the dialog displays the progress of a scan as it happens.

Running Fix IsDeleted as a Batch Job

The Fix IsDeleted tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool fixDeleted -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool fixDeleted -run configFile.copyStormMedic

Viewing Identified Problem Records

By checking the “Show Problems” checkbox, the application will store a list of all record IDs that are identified as being nonexistent (deleted) in Salesforce. To view the record IDs, run the tool, and after it is completed click the “Show Records” button. This will open up a modal window displaying the Table name, and Salesforce Record ID of all the records that were identified by the tool.

The “Show Problems” setting can be used to validate the data prior to anything being deleted. To use it in this way, ensure that “Show Problems” is enabled, and “Fix Problems” is disabled. With this configuration, the tool will search for and identify problem records, and generate a list of IDs that can then be used to query the backup database to validate data prior to deletion, or for use in identifying mistakenly deleted records in Salesforce.

In the Record viewer window, the resulting list of TableName:RecordID pairs can be exported as a .csv as well, using the “Export” button at the bottom of the modal window.

See below for an example of the record viewer window.

Viewing Identified Problem Records – When Running Via Terminal

When running the tool via command line, and using a config file which has the “Show Problems” flag enabled, the command line output of the application will include a list of all identified problem records. An example of this is shown below.

Refresh Columns

The CopyStorm/Medic Refresh Columns tool replaces the value of one or more columns in CopyStorm with their current values in Salesforce.

This tool is typically used when the definition of a formula is modified in Salesforce or when a previously hidden column becomes visible to the user CopyStorm uses to authenticate with Salesforce.

When one or more columns in CopyStorm do not match the current value in Salesforce there are two methods which can fix the problem:

  • Perform a forced update on the CopyStorm database using CopyStorm. This technique works but will cause every column in the CopyStorm tables to be read from Salesforce and written to CopyStorm, including columns whose data is already synchronized.

  • Use this tool to limit reads/updates from Salesforce to specific columns. This technique can be many times faster than a forced update, and does not re-synchronize data that is already synchronized.

Running Refresh Columns in a GUI

To access the Refresh Columns GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Data Synchronization”, then “Refresh Columns”.

The UI for the Refresh Columns tool contains three parts:

  • The side of the dialog is used to select the tables and columns to scan.

    • Click on a table name to launch a pop-up dialog for column name selection.

  • The top part of the dialog has parameters that determine the date range of records to be updated.

    • Leave these parameters blank to scan all records.

  • The lower part of the dialog displays the progress of a scan as it happens.

Clicking on a column name will cause a column selection dialog to appear:

Managing Stale Formulas Automatically

When a formula column definition changes in Salesforce, timestamps on Salesforce records do not change. In practice this means that a formula column in the CopyStorm database will not reflect the proper value after a formula definition change until the next time a non-formula field on the record changes.

Starting with CopyStorm 7.34.10, both formula column definition changes and the last formula column refresh time are tracked. The “Manage Stale Formulas Automatically” option takes advantage of this tracking and, when checked, will:

  • Automatically identify all formula columns whose definition has changed since their last refresh in CopyStorm, and add them to the column refresh set.

  • Once the formula columns are refreshed, CopyStorm will update the formula refresh time in its tracking tables.

Running Refresh Columns as a Batch Job

The Refresh Columns tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool refreshColumns -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool refreshColumns -run configFile.copyStormMedic

Refresh Formulas

The CopyStorm/Medic Refresh Formulas tool replaces the values of formula columns in CopyStorm with their current value in Salesforce.

This tool is typically used when the definition of a formula is modified in Salesforce.

CopyStorm minimizes the amount of records copied from Salesforce by only copying records whose modification date has changed. When a formula column is modified in Salesforce record modification times do not change so CopyStorm does not pick up the new formula values for older records. There are two ways to update this data in the CopyStorm database:

  • Performing a forced update on the CopyStorm database using CopyStorm. This technique works but will cause every column in the CopyStorm tables to be read from Salesforce and written to CopyStorm.

  • Using this tool to limit reads and updates from Salesforce to formula columns. This technique can be many times faster than a forced update.

Running Refresh Formulas in a GUI

To access the Refresh Formulas GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Data Synchronization”, then “Refresh Formulas”.

The Refresh Formulas tool contains three parts:

  • The side of the dialog is used to select the tables to scan. Note that if a table without formulas is selected it will be silently ignored by the tool.

  • The top part of the dialog is used to specify the date range of records to be updated. Leave these parameters blank to scan all records.

  • The lower part of the dialog displays the progress of a scan as it happens.

Running Refresh Formulas as a Batch Job

The Refresh Formulas tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool refreshFormulas -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool refreshFormulas -run configFile.copyStormMedic

Scan Timestamps

The CopyStorm/Medic Scan Timestamps tool performs an exhaustive comparison of Salesforce versus CopyStorm record modifications timestamps. This tool is provided for two reasons:

  • It can be used to provide assurance that CopyStorm is copying all records properly.

  • If Salesforce has an “after update” trigger on a table where the trigger updates the source table, this tool can be used to help track down the problem trigger.

Comparing modification timestamps from Salesforce with CopyStorm is a trickier task than one might think — here are a few of the reasons why:

  • Salesforce stores timestamps to the nearest millisecond.

  • Microsoft SQL/Server stores timestamps to the nearest 3 milliseconds.

  • MySQL stores timestamps to the nearest second.

  • Database to GMT time conversion works differently on different databases.

The Scan Timestamps tool will report the table, record id, timestamps, and timestamp difference for each record in Salesforce whose timestamp does not match CopyStorm and for records that are missing from CopyStorm. Records may be missing from CopyStorm due to being missed in a sync or because they will be synced in the future.

Run Scan Timestamps in a GUI

To access the Scan Timestamps GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Database Validation”, then “Scan Timestamps”.

The UI for the Scan Timestamps tool contains four parts:

  • The side of the dialog is used to select the tables to scan.

  • The top part of the dialog has parameters that determine the date range of records to be updated. Leave these parameters blank to scan all records.

  • The lower part of the dialog displays the progress of a scan as it happens.

  • If an error is detected a button will appear in the lower right hand corner. Click on the button to see error details and/or export the errors to a file.

NOTE: We purposefully corrupted the CopyStorm database so the “Show Problems” button would appear in the following screen shot.

If the Show Problems button appears, it can be clicked to show the details for each problem record.

In this example we corrupted the CopyStorm database by hand so the Salesforce database would contain records missing from CopyStorm. The following screen shot is the result of clicking on the “Show Problems” button:

Running Scan Timestamps as a Batch Job

The Scan Timestamps tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool scanTimestamps -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool scanTimestamps -run configFile.copyStormMedic

Table Editor

The CopyStorm/Medic Table Editor tool is for non-DBA people who want to remove data or tables from a CopyStorm database. Why would someone want to do this?

  • You may want to drop a specific table so CopyStorm will rebuild it the next time it runs. This case comes up when a column definition in Salesforce has changed and the corresponding change is not supported by the target database.

  • You may want to drop a Salesforce Feed table, like AccountFeed, so CopyStorm will replace it with a database view the next time it runs.

  • You may want to make CopyStorm completely forget about a database table it created. This action drops a table and all references to it in the CopyStorm metadata.

Without the Table Editor tool a DBA can always manually truncate or drop a table — this tool is designed to provide a way for a non-DBA to perform the same task.

Running Table Editor in a GUI

To access the Table Editor GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Rarely Used”, then “Table Editor”.

The UI for the Table Editor tool contains three parts:

  • The side of the dialog is used to select the tables to truncate, delete, or forget..

  • The top part of the dialog determines if the selected tables will be deleted, truncated, or forgotten.

  • The lower part of the dialog displays the progress of table modifications.

Running Table Editor as a Batch Job

The Table Editor tool cannot be run as a batch job.

Find Dirt

Find Dirt

The CopyStorm/Medic Find Dirt tool finds data in Salesforce fields that should not be possible. Capstorm provides this tool because, as a Salesforce instance ages, it will often accumulate data that does not match the field definition. Here are a few examples:

  • A string field is limited to 80 characters but has a few records where 96 characters are stored.

  • A numeric field is limited to zero digits after the decimal point but Apex code inserted records where digits appear.

This tool will report the table, record id, column name, and problem description for any field that does not match the Salesforce field definition.

Running Find Dirt in a GUI

To access the Find Dirt GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Salesforce Data Quality”, then “Find Dirt”.

The UI for the Find Dirt tool contains four parts:

  • The side of the dialog is used to select the tables to scan.

  • The top part of the dialog has parameters that determine the date range of records to be scanned.

    • Leave these blank to scan all records.

  • The lower part of the dialog displays the progress of a scan as it happens.

  • If an error is detected a “Show Problems” button will appear in the lower right hand corner.

    • Click the button to see error details and/or export the errors to a file.

If the “Show Problems” button appears, click it to show the details for each problem record.

Running Find Dirt as a Batch Job

The Find Dirt tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool findDirt -run configFile.copyStormMedic

  • Linux

    • sh CopyStormMedic.sh -tool findDirt -run configFile.copyStormMedic

Logging

The Logging Configuration Editor is used to configure CopyStorm logs that are written to the database, STDOUT / STDERR, or using the Apache Commons Logging framework.

Parameter Name
Default Setting
Required
Description

Database Logs in UTC

Base64 Sanity Checker

When the Salesforce REST API returns a record with a BASE64 column, the BASE64 data is returned as a hyperlink that can be used to read the raw bytes. Experience has shown that it is possible for the hyperlink returned by Salesforce to return a HTTP 404 (not found) or an HTTP 500 (internal lightning platform error) rather than the expected HTTP 200 (OK). When this happens:

  • The BASE64 data cannot be read by the REST API.

  • The same operation using the SOAP API results in an UNKNOWN_EXCEPTION or an unparsable SOAP body

The Base64 Sanity Checker tool tests the hyperlinks returned by the REST API and reports the ID of records where the hyperlink fails (e.g. Does not return a HTTP 200). It is often wise to check each reported record using the Salesforce GUI to make sure that the data is really available. If you find a corrupted Attachment record report it to Salesforce.

Running The Base64 Sanity Checker in a GUI

To access the Base64 Sanity Checker GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Salesforce Data Quality”, then “Base64 Sanity Checker”.

The only required parameters are the tables to search, but there are a number of other parameters you may want to modify.

Parameter
Description

The next step is to click on the Start Sanity Check button and wait for the analysis to complete. Note:

  • Each hyperlink check takes one Salesforce API call. There is one additional API call for every 2000 records.

  • An running analysis can be cancelled but the cancellation process may not be immediate. The reason is that pending HTTP requests must complete or timeout before the cancellation process is finished.

Hopefully when you scan your Salesforce the tool will not find potential problems. However, if potential problems are found then it is wise to check the validity of each record using the Salesforce GUI.

If you are using CopyStorm to perform backups, then this class of error will be discovered during the normal course of a backup. Unfortunately the error is often masked by an UNKNOWN_EXCEPTION or an Invalid SOAP Envelope response from Salesforce.

Fix ContentDocumentLinks

The Fix DocLinks tool repairs records in the Salesforce ContentDocumentLink table. The Salesforce ContentDocumentLink table has query restrictions that make it impossible to efficiently perform an 100% accurate incremental backup. There are two primary reasons that block an 100% accurate backup.

  1. The ContentDocumentLink table cannot be queried only on its SystemModStamp field.

  2. ContentDocumentLink permission values can be changed and there is no way to find the changes efficiently because of reason #1.

In practice most customers will either never run this tool or run it on a weekly basis.

Running Fix DocLinks in a GUI

To access the Fix DocLinks GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Data Synchronization”, then “Fix DocLinks”.

The UI for the Fix DocLinks tool is minimal.

  • The top of the dialog controls how many concurrent queries to run against Salesforce and what data ranges to scan.

  • The middle part of the dialog has a large button for starting the search and text for reporting progress

The tool will report progress as it scans records and when finished will look like:

where:

  • Candidates = total # of ContentDocumentLink records scanned

  • Inserted = number of ContentDocumentLink records inserted into the CopyStorm database.

  • Update = number of ContentDocumentLink records updated in the CopyStorm database.

The Fix DocLinks tool can be run as a batch job using the following syntax:

  • Windows

    • CopyStormMedic.bat -tool fixDocLinks -run configFile.copyStormMedic

  • Linux or Mac

    • sh CopyStormMedic.sh -tool fixDocLinks -run configFile.copyStormMedic

Count Records

The CopyStorm/Medic Count Records tool performs a comparison of object record counts in Salesforce versus CopyStorm. This tool is provided as a sanity check for backup validation, to provide assurance that CopyStorm is copying all records properly.

Run Count Records in a GUI

To access the Count Records GUI:

  • Select “Other Tools” from the top-level menu.

  • Select “Database Validation”, then “Count Records”

The UI for the Count Records tool contains four parts:

  • The left-hand side of the dialog is used to select the tables to scan.

  • The top part of the dialog has the following parameters:

    • of Tables to Process Concurrently.

      • Specifies how many tables the tool will process in parallel. Higher values may improve performance but increase resource usage.

    • Output To CSV (checkbox).

  • The lower part of the dialog displays the progress of a record count analysis as it happens.

  • If an error is detected, a button will appear in the lower right hand corner. Click on the button to see error details and/or export the errors to a file.

  • Windows

    • CopyStormMedic.bat -tool countRecords -run configFile.copyStormMedic

  • Linux / Mac OS

Help! Partition Creation Failed

When partitioning tables containing large volumes of data or Base64-encoded content, the partition creation process can fail mid-way due to various issues, such as:

  • Application freezes or crashes

  • Transient network errors

  • Resource exhaustion (e.g. memory or CPU spikes)

  • Timeouts or I/O bottlenecks

These interruptions can leave partitions in an incomplete or inconsistent state.

The Partition Creation process is designed to be incremental:

  • Records are copied from Source to Target Partition in an ID-based ordering (lexicographical).

  • After each batch of records is copied from Source to Target, the last read Salesforce ID is persisted in the Database.

    • See the CopyForceTablePartitionLoadTask database table.

Note: CopyStorm will refuse to replicate data to a table if it has a Partition Creation In-Progress

If partition creation fails, you can resume the process by navigating back to the Partition Editor Tool. You’ll see the following dialog appear if a partition creation is in-progress:

From this point, you’ll have the option to:

  • Resume the Partition Creation process

    • This will start copying data from Source to Target from the Last Read Salesforce ID.

  • Cancel the Partition Creation process

    • Note: Cancelling will not remove data already copied if the Source is S3 or a Folder

Main Tab

The Main Tab is used to manage connection information and credentials for Salesforce and the target database.

Specifies the type of target database. Available database targets depend on the version of CopyStorm you have installed.

These parameters are used when authenticating with Salesforce using a Username and Password.

  • For certificate based authentication, see the .

  • For SSO-based authentication, see .

Database Schema

The Database Schema Configuration Editor contains parameters used to configure CopyStorm database schema generation.

Parameter Name
Default Setting
Required
Description

Core Configuration

The Core Configuration Editor is used to specify which objects should be replicated to the database, and to control how long records will be retained in the database after being deleted in Salesforce.

The “Select Objects” dropdown selects the objects which will be copied from Salesforce to the database.

The easiest way to configure which objects to copy is to select one of the pre-configured options:

  • All Objects

    • Copy all Salesforce objects that the CopyStorm Salesforce User has access to.

How to Solve UNKNOWN_EXCEPTION Errors

On rare occasions a site may receive an UNKNOWN_EXCEPTION from CopyStorm. In CopyStorm’s log, the error will look like:

10-Feb-17 09:02:11: [UnexpectedErrorFault [ApiFault exceptionCode=’UNKNOWN_EXCEPTION’ exceptionMessage=’An unexpected error occurred. Please include this ErrorId if you contact support: 303701882-51722 (1187285824)’ extendedErrorDetails='{[0]}’

This error is generated by Salesforce’s server when it encounters a problem that Salesforce code does not know how to handle. Most of the time the issue will resolve itself after a couple days as Salesforce fixes their own internal problems. If the problem does not clear up automatically then this article may help you resolve the issue.

In Capstorm’s experience, to get Salesforce support to pay attention to UNKNOWN_EXCEPTION issues a problem has to be reproduced in an application supplied totally by Salesforce. When this error is being given by Salesforce we need to:

  • Isolate the SOQL query in CopyStorm that is causing the problem.

Lineage Maintenance

The CopyStorm/Medic Lineage Maintenance Tool is used to view lineage data & invalidate problematic lineage records.

Over time, a Record’s lineage may be invalidated:

  • One of the legacy lineage entries may no longer exist in the CopyStorm Database or Snapshot.

  • Records may have multiple children, causing split lineage.

For more details on Record Lineage, .

How are S3 Partitions Structured?

When CopyStorm writes data to an S3 partition, each Salesforce record is stored as one or more files in your S3 bucket. The location of every file is derived entirely from the Salesforce record ID. There are no date folders, job ID folders, or table name folders.

The folder hierarchy is constructed by slicing the first 13 characters of the Salesforce record ID into five segments:

Segment
Characters
Example (ID: 001ZZ010000000000AA)

CopyStorm/SanityChecker

As of CopyStorm/Medic 10.54.2, the Base64 Sanity Checker function has been merged into CopyStorm/Medic.

For the latest documentation, please see:


When the Salesforce REST API returns a record with a BASE64 column, the BASE64 data is returned as a hyperlink that can be used to read the raw bytes. Experience has shown that it is possible for the hyperlink returned by Salesforce to return a HTTP 404 (not found) or an HTTP 500 (internal lightning platform error) rather than the expected HTTP 200 (OK). When this happens:

dd-MM-yy (19-5-84)

  • yyyyMMdd (19840519)

  • Bulk Limit

    No

    Controls the number of records that will be retrieved with each Bulk API call. A larger value will cause each Bulk API call to take longer but minimize the number of Bulk API calls. If this parameter is not specified it defaults to the SOAP Limit for the current table.

    Bulk Polling Rule

    No

    Sets the polling rate CopyStorm uses to check if a Bulk API operation has completed. The format of this parameter is a comma separated list of numbers where each number indicates how many seconds to wait between each poll of Salesforce.

    For example, the rule 1,3,5,10,10,10,30 means:

    • Poll Salesforce after 1 second the 1st time.

    • Poll Salesforce again 3 seconds after the 1st check.

    • Poll Salesforce again 5 seconds after the 2nd check.

    • Poll Salesforce again 10 seconds after the 3rd through 5th check.

    • Poll Salesforce every 30 seconds after the 5th check.

    Max Bulk API Calls

    No

    The maximum number of Bulk API calls that will be used in a single CopyStorm session.

    this article

    Running Fix DocLinks as a Batch Job

  • If checked, headless runs of Count Records will output tool results to STDOUT and Database Logs in CSV-compliant format.

  • sh CopyStormMedic.sh -tool countRecords -run configFile.copyStormMedic

    Running Count Records as a Batch Job

  • Cancelling a JDBC Partition Creation will delete the new JDBC Partition.

  • Source data will never be deleted during the cancellation process.

  • Unchecked

    No

    If checked, timestamps recorded in CopyStorm’s job tracking log tables will be in UTC rather than local time.

    Log Tables with No Activity

    Unchecked

    No

    If checked, CopyStorm will log tables with no activity (no records copied, skipped, deleted, or archived) during a job.

    Log Format

    Full

    No

    This option controls the amount of detail sent to the CopyStorm log file. Options include:

    • Compact: Display a single line of text for each table that has copy activity.

    • Summary: Display a single line for each table processed (even if no records were copied).

    • Full: Display a verbose amount of logging information.

    • Debug: Display everything Full displays, plus additional debugging information.

    Log Table Sizes

    Checked

    No

    If checked, log the starting and ending table sizes in bytes.

    Use Apache Logging

    Unchecked

    No

    If checked, logging will be performed with the Apache Commons Logging framework. By default, Log4j will be used.

    Debug Mode

    Unchecked

    No

    If checked, CopyStorm will output logging messages to the debug console (normally hidden).

    Silent Mode

    Unchecked

    No

    If checked, when running in batch mode, CopyStorm will only display errors to stderr and will not display debug or informational messages.

    SFDC Logging

    Off

    No

    This option enables CopyStorm-to-Salesforce job logging. Options include:

    • On: Write job logging information to Salesforce (If Salesforce logging is not supported, logging information will not be pushed and the job will proceed normally).

    • Off: Do not write job logging information to Salesforce.

    • Required: Write job logging information to Salesforce (if Salesforce logging is not supported, the job will abort).

    CopyStorm contains backend support only for Salesforce Logging. To enable Salesforce support for this feature, contact your Capstorm account representative.

    SFDC Logging Interval

    2

    No

    This option sets the time interval (in minutes) between pushes of job logging information to Salesforce.

    CopyStorm contains backend support only for Salesforce Logging. To enable Salesforce support for this feature, contact your Capstorm account representative.

    SFDC Log Count

    4

    No

    This option configures how many job logs for the CopyStorm configuration file are kept in Salesforce. When CopyStorm creates a new job log, older job log records are deleted, retaining records according to this option. For example:

    • With a value of 0, only the most recent job will be retained.

    • With a value of 5, only the most recent job log and the 5 previous job logs will be retained.

    • If this field is left blank/empty, all job logs will be retained.

    CopyStorm contains backend support only for Salesforce Logging. To enable Salesforce support for this feature, contact your Capstorm account representative.

    SFDC Log Retention

    4

    No

    This option determines how long job logs for all configuration file are kept in Salesforce before older log records are deleted. Job logs that are older than this many days are deleted. This option overrides the SFDC Log Count option if the SFDC Log Count option would cause job logs to be retained for more than this many days. For example:

    • With a value of 0, only the most recent job will be retained.

    • With a value of 5, only the most recent job log and logs from the previous 5 days will be retained.

    • If this field is left blank/empty, all job logs will be retained.

    CopyStorm contains backend support only for Salesforce Logging. To enable Salesforce support for this feature, contact your Capstorm account representative.

    # Checker Threads

    Number of base 64 hyperlinks to analyze concurrently.

    Max Timeout (sec)

    Number seconds to allow for each hyperlink test. If a hyperlink HTTP request times out it is assumed to be OK based on Capstorm’s experience with problem records. Setting this to a smaller value may improve the overall throughput of the analysis.

    Report Timeouts

    If this option is checked then all HTTP timeouts will be reported as potential problems. Enabling this feature may be useful in selecting an optimal Max Timeout value for your organization.

    Modified After

    Search for records starting at this date. A date can be selected from the menu or typed in directly. Values are restricted to datetime formats supported by SOQL.

    Modified Before

    Search for records up to this date. A date can be selected from the menu or typed in directly. Values are restricted to datetime formats supported by SOQL.

    Salesforce Batch Size

    Step 1: Set Search Parameters

    Step 2: Check Hyperlinks

    Summary

    Number of records to process from Salesforce in a single batch. The default usually provides optimal performance.

    No

    CopyStorm uses a relaxed definition for all Salesforce numeric columns. This is because it is possible for Salesforce to store values that do not match the declared field definition. An example is the computed column Opportunity.Amount, which can be forced to exceed the field size declared by Salesforce.

    By default, CopyStorm uses:

    • NUMERIC for Oracle and PostgreSQL databases.

    • DECIMAL for SQL/Server, MySQL, and H2 databases.

    Extra Precision

    2

    No

    Increases the numeric precision stored by the database by this number of digits, both before and after the decimal point. The default value is almost always a good choice and works around the handful of instances where Salesforce “lies” about the precision of a column.

    AnyType Length

    Blank

    No

    Allocate this many characters for Salesforce columns using the AnyType data type. Use of an AnyType column is rare and only seen in Salesforce system level tables. The default length is 255.

    Use Database Views

    Checked

    No

    If checked, CopyStorm will create database views for Salesforce objects that can be represented as such. For example, all Feed objects can be represented as views on FeedItem.

    Obfuscate Schema

    Varies

    No

    If checked then CopyStorm will obfuscate database table and column names.

    Use NVARCHAR2

    Unchecked

    No

    If checked and using Oracle, use NVARCHAR2 for String data. If unchecked, assume that the encoding used by Oracle is capable of representing all UTF8 characters. This option is only used when copying to Oracle databases.

    Table Prefix

    Blank

    No

    If set, all Salesforce backup tables created by CopyStorm will be prefixed with this value.

    For example, if “Table Prefix” is set to “SF_” then the Account table will be created as “SF_Account” rather than “Account”. Note that this parameter has no effect on tables that have already been created by CopyStorm.

    Continue on DML Errors

    Checked

    No

    If checked, CopyStorm will continue processing if a DML error is encountered. A DML error typically occurs when the structure of a Salesforce table has changed in a way that causes an “ALTER TABLE COLUMN” command to fail in the target database. The simplest fix is to drop the table in the target database and let CopyStorm rebuild it.

    If checked, CopyStorm will log an exception, skip the problem table, and continue with the next table.

    Include Formulas

    Checked

    No

    If checked, CopyStorm will create columns corresponding to formula fields in Salesforce and will copy down the formula data into the columns. If unchecked, CopyStorm will ignore formula fields.

    Include Base64

    Checked

    No

    This option controls how CopyStorm will handle Base64 fields (file data). Possible values are:

    • Default – CopyStorm will only copy file data if the database supports long CLOB columns.

    • Yes – CopyStorm will always try to copy file data, whether or not the database supports it.

    • No – CopyStorm will never try to copy file data even if the database supports it.

    Chunk Base64 Values

    Unchecked

    No

    If checked, CopyStorm will store all Base64 values as chunks. These chunks will be specified in the “CopyForceTableFieldChunk” table in the CopyStorm database.

    Synchronize Schema

    Checked

    No

    If checked, CopyStorm will create and alter database columns to match Salesforce definitions/metadata. If unchecked, CopyStorm will not attempt to alter database schema definitions when Salesforce object/field definitions change.

    Auto Upgrade Schema

    Checked

    No

    Upgrade the database schema to match the schema for this version of CopyStorm.

    If checked:

    • The CopyStorm Database will be updated without explicit user approval.

    If unchecked:

    • The user will be prompted with planned CopyStorm database additions, deletions, or changes. The database upgrade will not occur until the user approves the action.

    • When running in headless mode, CopyStorm will terminate with an Exception indicating the need for database schema upgrade approval.

    Use Strict DECIMALs

    Unchecked

    Run the query in the Salesforce console to prove that the query is causing the issue.

  • Submit a case to Salesforce.

    1. Start CopyStorm from a command line window with the “-debug” command line switch.

      1. CopyStorm.bat -debug

      2. sh CopyStorm.sh -debug

    2. On the Advanced tab, select “Debug Mode” under “Misc Options”.

      1. You may have to select “Show All Options” to see the “Debug Mode” option.

    3. Start a copy. The SOQL query causing the issue will appear in the command line window.

    4. Copy the SOQL and save it to a file.

    1. Login to the Salesforce GUI.

    2. Choose “Developer Console” in the menu that appears when you click on your name.

    3. Paste the SOQL query into the editor.

    4. Press the execute button.

    5. Copy the error text and save it.

      1. The error should appear in the lower part of the screen.

    • Describe what you did in Step 3.

    • Include the problem SOQL and the error text from Step 3.

    First level support can rarely solve this sort of issue and you should expect a request to grant access to your system so Salesforce engineers can reproduce the error.

    Though we do not see this error often, it has appeared a few times when Salesforce index corruption of their Oracle database caused the issue. Truthfully we cannot know the precise root cause unless Salesforce exposes it — to any application it is only exposed as a type of error that Salesforce does not expect to occur.

    How to Solve UNKNOWN_EXCEPTION Errors

    Step 1: Isolate the SOQL Query in CopyStorm

    Step 2: Run the SOQL Query in the Salesforce Console

    Step 3: Submit a Support Case to Salesforce

    Why Does This Type of Error Happen?

    Parameter

    Description

    Instance Type

    Type of Salesforce instance being copied.

    • Production

    • Sandbox

    • Database.com

    Username

    A Salesforce user. This user must have API privileges. All data visible to this user will be copied to the CapStorm database.

    Password

    The password for the Salesforce user.

    Parameter
    Description

    Credential Type

    Technique used to find the Salesforce password. The default, Username and Password, stores encrypted credentials in a project’s .copyStorm configuration file. To login to Salesforce using the JWT Oauth flow, change this to “Oauth 2.0 JWT” and see the . To login using an SFDX registered instance, change this to “SFDX Username or Alias” and see the .

    Salesforce Batch Size

    Default number of records to read from Salesforce in a single batch. The default, 2000, is the maximum supported by Salesforce and should not be changed unless the host machine has severe memory limitations. Decreasing this value will increase the number of API calls to Salesforce.

    Max Timeout

    Parameter

    Description

    Connection String

    JDBC connection string required to create a CopyStorm database.

    Connection String Builder

    Clicking on this button launches a dialog that helps create a valid connection string.

    Username

    • MySQL

    • Oracle

    • PostgreSQL

    • SQL/Server

    Copy Salesforce To

    Salesforce Connection Parameters

    Oauth 2.0 JWT Configuration reference
    How to Login to Salesforce using SSO

    Salesforce Advanced Parameters

    Database Connection Parameters

    Database-Specific Configuration

    Automatically copy newly created Salesforce Objects when they become visible to the CopyStorm Salesforce User.

  • All Objects Except for Files

    • Copy all Salesforce objects that the CopyStorm Salesforce User has access to, except for Base64/File objects (e.g. Attachment, ContentVersion).

    • Automatically copy newly created Salesforce Objects when they become visible to the CopyStorm Salesforce User.

  • All Objects That Can Be Restored

    • Copy all Salesforce objects that the CopyStorm Salesforce User has access to, except for objects that are known to not be recoverable (e.g. External objects, History objects).

    • Automatically copy newly created Salesforce Objects when they become visible to the CopyStorm Salesforce User.

  • To configure CopyStorm to copy specific objects, select from the “Manual Selection” options. Selecting a “Manual Selection” will show an “Include” or “Exclude” list. To configure the list, either:

    • Type or copy-paste the API names of selected objects into the “Select Objects…” section as a comma separated list.

    • Click on the “Select Objects…” button.

      • This will cause CopyStorm to connect to Salesforce to determine the Objects available.

      • A dialog will open allowing selection of available Salesforce Objects.

    Manual selection options include:

    • Manual Selection – Include List: Choose Objects to Include

      • All selected objects will be copied.

    • Manual Selection – Exclude List: Choose Objects to Exclude

      • All objects visible to the CopyStorm Salesforce User will be copied, except for selected objects.

      • Automatically copy newly created Salesforce Objects when they become visible to the CopyStorm Salesforce User.

    • Manual Selection – Advanced: Choose Objects to Include and Exclude

      • If the Include list is empty, all Salesforce Objects will be copied, except for objects selected in the Exclude list.

      • If the Include list is not empty, all selected objects will be copied.

    The “Delete Older Than” input controls when to remove records that have been deleted from Salesforce from the target database.

    • 0 (zero): This is the default value. Remove deleted records immediately from the target database.

    • Blank (no value specified): Mark deleted records as IsDeleted, and never remove deleted records.

    • A non-zero number: Mark deleted records as IsDeleted, and remove records when they have been deleted from Salesforce for the number of days specified by “Delete Older Than”.

    CopyStorm discovers deleted records by reading the Salesforce recycle bin. If the recycle bin is emptied before CopyStorm discovers the deletion, or if records have been removed with a hard delete, CopyStorm will not know that the records are deleted. This method is used by some applications. If this is occurring, please use Capstorm’s CopyStorm/Medic tool to discover the deleted records and mark the records as IsDeleted in the target database.

    If the “Include Metadata” checkbox is checked, CopyStorm will include selected metadata components in the backup. By default, if checked, all metadata components are included.

    Clicking the "Edit" button next to this checkbox opens the metadata selection dialog.

    The Metadata Selection Mode dropdown offers three options:

    • All Metadata Types — All available Salesforce metadata types are backed up. This is the default. Any new metadata types added by Salesforce in the future will automatically be included.

    • Include Selected Types — Only the specific metadata types selected from the list will be backed up. Use this to back up a small, known set of types and ignore everything else.

    • Exclude Selected Types — All available metadata types are backed up except the ones selected from the list. Use this for broad coverage but need to omit a few specific types. Like "All Metadata Types," any new metadata types added by Salesforce in the future will automatically be included. The exclusion list is applied against whatever is currently available, not a fixed snapshot.

    The dialog also includes:

    • Include Managed Packages — When checked, metadata from managed packages is included in the backup.

    • Delete Metadata History after N days — Controls how long historical versions are retained. Leave blank to keep history indefinitely; set to 0 to keep only the current version with no history.

    Select Objects

    Delete Older Than

    Include Metadata

    Select “Other Tools” from the top-level menu.

  • Select “Data Synchronization” and then “Lineage Maintenance”

    • Optionally Configure Modified After & Modified Before

      • This will control what date ranges are queried for lineage.

      • Leaving these values Blank will query all time lineage.

    • Optionally Enable Validators

      • Purged Record Validation

        • Identifies lineage entries that do not have a corresponding physical record in the CopyStorm Database or Snapshot.

      • Branching Lineage Validation

        • Identifies lineage entries that have multiple children.

    • Optionally toggle “Only Show Invalid Lineages” checkbox

      • This should be used when investigating invalid lineages.

    • Click “Start Scan”

    After clicking “Start Scan”, the application will render a view of:

    • All Lineage within the provided Modified After / Modified Before values.

    • The Status of each Lineage.

      • Valid

        • If there are no branches and all lineage entries exist in the CopyStorm Database or Snapshot

      • Invalid

        • If branch(es) are detected or any entry is missing from the CopyStorm Database or Snapshot

    • The associated Salesforce Table for the Lineage.

    • The Salesforce ID of the Lineage HEAD

      • HEAD is the most recent entry in the Lineage.

    Use the “Invalidate Selected Lineage” to mark problematic Lineage Entries as Invalid in the database.

    Note: Invalidating Lineage will prevent CopyStorm/Restore from considering invalid entries as recovery candidates.

    An example of viewing a full lineage is shown below:

    Using the Tool

    refer to this article

    001ZZ

    Level 2

    5–6 (2 chars)

    01

    Level 3

    7–8 (2 chars)

    00

    Level 4

    9–10 (2 chars)

    00

    Level 5

    11–12 (2 chars)

    00

    Full example path for the example ID:

    Each record produces at least one file and potentially more.

    Main record file: Always present, contains all standard field values as XML:

    Large field files: Created for any field whose value exceeds 5 KB (e.g. Body on ContentVersion). The main XML file references these by name; the data is stored separately:

    Example for a file attachment:

    Included in path?

    Bucket name

    Yes (configurable)

    Folder prefix

    Yes (configurable, may be empty)

    AWS region

    s3://[bucket]/[folder]/[chars 0–4]/[chars 5–6]/[chars 7–8]/[chars 9–10]/[chars 11–12]/[filename]

    Level 1

    Path Format

    0–4 (5 chars)

    s3://my-bucket/my-folder/001ZZ/01/00/00/00/001ZZ010000000000AA.xml
    [recordId].xml
    [recordId].[fieldName].txt
    001ZZ010000000000AA.xml
    001ZZ010000000000AA.Body.txt

    Files Per Record

    What Is and Isn't in the S3 Path

    The BASE64 data cannot be read by the REST API.
  • The same operation using the SOAP API results in an UNKNOWN_EXCEPTION or an unparsable SOAP body

  • The CopyStorm/SanityChecker tool tests the hyperlinks returned by the REST API and reports the ID of records where the hyperlink fails (e.g. Does not return a HTTP 200). It is often wise to check each reported record using the Salesforce GUI to make sure that the data is really available. If you find a corrupted Attachment record report it to Salesforce.

    The only required parameters are the tables to search, but there are a number of other parameters you may want to modify.

    Parameter
    Description

    Modified After

    Search for records starting at this date. A date can be selected from the menu or typed in directly. Values are restricted to datetime formats supported by SOQL.

    Modified Before

    Search for records up to this date. A date can be selected from the menu or typed in directly. Values are restricted to datetime formats supported by SOQL.

    Salesforce Batch

    The next step is to click on the Start Sanity Check button and wait for the analysis to complete. Note:

    • Each hyperlink check takes one Salesforce API call. There is one additional API call for every 2000 records.

    • An running analysis can be cancelled but the cancellation process may not be immediate. The reason is that pending HTTP requests must complete or timeout before the cancellation process is finished.

    While the sanity check is in process, the tool will look like the following:

    The following example shows what a report of potential problems looks like. You can copy/paste the potential problems into your favorite editor.

    Hopefully when you scan your Salesforce the tool will not find potential problems. However, if potential problems are found then it is wise to check the validity of each record using the Salesforce GUI.

    If you are using CopyStorm to perform backups, then this class of error will be discovered during the normal course of a backup. Unfortunately the error is often masked by an UNKNOWN_EXCEPTION or an Invalid SOAP Envelope response from Salesforce.

    base64-sanity-checker

    Step 1: Enter Salesforce Credentials

    Step 2: Set Search Parameters

    Step 3: Check Hyperlinks

    Summary

    History Tab

    Each time CopyStorm runs it records job information and statistics into a set of history logging tables within the CopyStorm database. The History Tab supports viewing and exporting CopyStorm job history.

    The History Tab consists of two sections — a top section used to search for past CopyStorm jobs and a bottom section displaying a one-line status for each job in the database.

    CopyStorm Job History

    Job History Table Headers

    Column Name
    Description

    View...

    When the “View…” column is clicked a dialog appears providing detailed job status. This dialog is similar to the “Copy in Progress” GUI but only contains tables that had activity in the selected job.

    Column Name
    Description

    Any exceptions that occurred during the job will be displayed in the Exceptions tab. In this example, the job had a single exception.

    Column Name
    Description

    When the “View…” column is clicked a dialog appears providing detailed job status:

    In addition to viewing historical job data, the History Tab can be used to delete job records and to export job data to Excel-compatible CSV files.

    To delete records:

    • Click on the check box next to one or more Job #.

    • Click on the “Delete” button.

    To export job history to CSV files:

    • Click on the check box next to one or more Job #.

    • Click on the “Export” button.

    Notifications

    The Notifications Tab contains parameters used to control who receives a status email when a CopyStorm/Medic job runs and under what circumstances email is sent. CopyStorm/Medic supports email notifications via SMTP or via a Salesforce SOAP API call.

    SFDC Notifications

    Parameter Name
    Required
    Description

    Send Email To

    Yes

    Parameter Name
    Required
    Description

    Snapshot Policy Editor

    CopyStorm Snapshots support an unlimited number of Snapshot Policies with each Policy defined by the Snapshot Policy Editor. The following image lays out the primary sections of the Snapshot Policy Editor.

    There are several tabs on the Snapshot Policy Editor.

    • The Main tab contains properties common to all snapshots and is where the Filter Rule Type for the snapshot is indicated.

    • The Filter Rule Parameters tab contains filter specific data. For example:

      • Most filter types support selecting which tables to include in a snapshot.

      • The Column Expression filter type supports rich user supplied expressions to limit which records are snapshot.

    • The Advanced tab contains parameters rarely modified by a customer.

    The following subsections describe each tab in details.

    Each Snapshot Policy requires a unique name. There are no restrictions on what characters can appear in a name but the name itself must be unique for each snapshot policy.

    A Snapshot Policy is always in either an Active or Inactive state.

    • A policy in an Active state will be be used by CopyStorm as part of a normal backup. For example, the Default Recycle Bin policy will usually be set to an Active state so the backup will automatically snapshot records as they are deleted from Salesforce.

    • A policy in an Inactive state can be ran by hand but will not be automatically processed as part of a CopyStorm backup. Inactive policies are useful for one-off compliance needs and snapshot policies that do not need to be part of a scheduled process.

    The Apply Policy section controls when CopyStorm will check a record in the database against the policy filter. There are three options:

    • After Insert — check a record against the policy immediately after it is inserted into the CopyStorm database.

    • Before Update — check a record against the policy immediately before it is updated with changes from Salesforce.

    • After Update — check a record against the policy immediately after it has been updated in the CopyStorm database.

    One or all of the option can be selected concurrently. In all cases, CopyStorm will not add a record to a snapshot if an identical copy of the record is already in the snapshot.

    To reduce the amount of database space required to snapshot a record, certain non-essential fields can be excluded. Common exclusion choices are:

    • Empty Fields — when empty fields are excluded a savings of the “length of the field name” plus 3 bytes is saved for each of the record’s empty fields.

    • Formula Fields — excluding a formula field can often save a lot of space in a record. Formulas are computed, so there is no data loss.

    The # Days to Retain parameter controls how many days records are kept in a snapshot before they are deleted.

    • Blank means to keep snapshot records forever.

    • 90 means to delete snapshot records after 90 days.

    In addition to the global # Days to Retain parameter, the policy for individual tables in a snapshot can be set explicitly by creating an override rule using the Advanced.. button. Clicking on the Advanced… button launches the .

    The Filter Rule Type specifies specific properties that a record must have to be considered by the snapshot policy. Example Filter Rule Types include:

    • Deleted Records — a record passes the filter if it has been deleted in Salesforce.

    • Column Expression — a record passes the filter if the data in its columns matches a user defined expression.

    • All Changes — a record always passes the filter.

    For further details for each filter rule type, see the article on .

    The content of the Filter Rule Parameters tab depends on the Filter Rule Type selected on the Main tab.

    For example, the following screen shot is for a Column Expression filter rule.

    • This filter says to only snapshot a record if it is a Contact or Account and is named CapStorm.

    • Like most filters, the tables to be processed by the rule can be specified as a White List, Black List, or both.

    For further details for each filter rule type, see the article on .

    To boost performance of record relationship traversal, CopyStorm Snapshots maintain a high speed database index. This section supports excluding reference fields from the high speed index to save space in the database. The reference fields selected by default are rarely needed for relationship traversal, occur on nearly every record, and thus can take up significant space in the CopyStorm Snapshot index.

    Partition Editor

    The CopyStorm/Medic Partition Editor tool modifies the schema of the CopyStorm database to vertically partition CopyStorm Salesforce data tables into multiple database tables.

    This tool is typically used when a Salesforce object is wide enough that it cannot fit into a single SQL database table. For example, if the Salesforce Account and Contact objects both have the maximum number of custom fields and Person Accounts are enabled. This can cause a single Salesforce object to have more than 1,000 fields.

    In the scenario where partition creation fails for any reason, the next partition creation attempt will pick up where the last partition creation failed. When a partition is in a partial state due to a failure, CopyStorm jobs will skip over backing up records to this table until the partition is completed.

    This CopyStorm/Medic tool provides a way to resolve database error messages indicating that a record is too large to fit in a database table:

    • MySQL: “Row size too large (> 8126)”

    • SQL/Server: “Cannot Create a row of size 8765 which is greater than the allowable maximum row size of 8060”

    • PostgreSQL: “row is too big”

    To access the Partition Editor GUI:

    • Select “Other Tools” from the top-level menu.

    • Select “Partition Editor” in the dropdown.

    A list of objects in the CopyStorm database is displayed on the left – select an object to view its partition configuration. After selecting an object, the following information will be displayed:

    1. Partition Name

      1. The CopyStorm database table name for the table storing the field.

    2. Field Name

      1. The Salesforce field name.

    To move fields between partitions, or to create a new partition, click on the “Move Fields” button. This button will open a pop-up window displaying available partitions and configuration options to configure a new partition.

    The “Move [Object] Fields To” drop-down controls the target partition.

    • If a pre-existing partition name is selected, then any fields already in the target partition will not be available to select.

    • If the “New JDBC Partition” option is selected, then CopyStorm/Medic will create a new database table to hold the selected fields.

    Configuration parameters for the target partition type will be displayed below the drop-down.

    Data partitions can be created in:

    • The SQL Database, as a new JDBC Table.

    The following screenshot displays the configuration panel for creating a new JDBC Database Table partition:

    Clicking on the “Continue” button will open a pop-up for Field Selection:

    • All selected fields will be moved to the target partition.

    • The source partition for each field is displayed next to the field name.

    After clicking on the “Review Changes” button, the selected fields will be displayed – highlighting the source partition(s) that currently contain the fields.

    To perform the changes and update the CopyStorm database schema, click on the “Apply Changes” button. Clicking on the “Apply Changes” button will cause CopyStorm to:

    1. DROP from the target partition any pre-existing columns for the selected fields.

      1. This is to ensure that the partitioning process can be retried should any issues be encountered during the partitioning process.

    2. Create schema in the target partition.

    While the partitioning process is running, status will be displayed in the “Log” tab. When the partitioning process has completed, the log will indicate that the job has finished.

    After closing the pop-up, the Partition Editor will display the new status of the selected fields.

    How to Transform Field Data During a Backup

    CopyStorm supports dynamic transformation of field data after reading it from Salesforce and before it is written to the target database. This article describes how to add a new custom transformation to CopyStorm.

    History of This Feature

    This issue first arose when a customer wanted to scramble Salesforce data for certain fields before it was written to the target database. Since the customer needed total control over the data manipulation process, an extension was added to CopyStorm to dynamically add field transformations. This allows you to write custom code to perform operations like:

    • Scramble email addresses – instead of replicating plain-text email addresses, obfuscated emails could be replicated.

    • Scramble sensitive data such as social security numbers or Contact health information.

    Most customers do not require this feature — it is only used when Salesforce data needs to be modified prior to being added to a local relational database. As CapStorm’s data recovery features will recover the exact data that is stored in the database, it is always best practice to write unmasked data to the database.

    The process of adding a new data transformer is not difficult — all that is required are the following steps:

    1. Write a Java class that implements the Capstorm interface com.aslan.sfdc.extract.transform.ITransformer.

    2. Add a TransformerRegistry.xml file to CopyStorm’s config directory to register the new transformer with CopyStorm.

    3. Update the TableRuleRegistry.xml file to enable the new transformer for the appropriate fields.

    The rest of this article describes the development and deployment process for adding a new data transformer to CopyStorm that reverses any input string.

    Example: The transformer in this article will turn “Capstorm” into “mrotspaC”.

    The following code is an example data transformer implementation. After creating a new data transformer, package it in a jar and store the jar file in the “lib” subdirectory of the CopyStorm installation directory.

    CopyStorm discovers available transformers by looking for a file named TransformerRegistry.xml in the CopyStorm config directory.

    The following TransformerRegistry.xml will cause CopyStorm to load the “Reverse” transformer:

    The Transformer directive adds a new custom transformer using the following attributes:

    • name — the friendly name used to apply the transformer to a particular Salesforce field.

    • class — the full name of a class that implements the ITransformer interface.

    CopyStorm discovers field transformations by looking for FieldTransform elements in the TableRuleRegistryFile.xml configuration file in CopyStorm’s config directory. The general format of this file is described .

    The following TableRuleRegistry.xml will cause CopyStorm to reverse the letters in the LastName for all Contacts before writing the LastName to the database:

    FieldTransform configuration directives have the following options:

    • name — the name of a field in the corresponding Salesforce table.

    • transformer — the name of a registered transformer that will be applied to the field data. This is the same as the name specified in Step 2.

    If your custom transformer is having no effect on data then the problem is likely in the new XML configuration directives.

    To verify that your entry to TableRuleRegistry.xml is correct, use one of the built-in CopyStorm transformers. Built-in transformers include:

    • Scramble — replace each letter with a different letter, replace each number with a different number.

    • Blank — return a blank string.

    If CopyStorm’s built-in transformer works then the problem is either in your TransformerRegistry.xml file or in your code. Put some debugging in your transformer to see if it is ever being called.

    • If it is not being called, the problem is in the TransformerRegistry.xml file.

    • If it is being called, then fixing the code is up to you!

    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 .

    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.

    Notifications Tab

    The Notifications Tab contains parameters used to control who receives a status email when a CopyStorm job runs and under what circumstances email is sent. CopyStorm supports email notifications via SMTP or via a Salesforce SOAP API call.

    Parameter Name
    Required
    Description

    Configured separately, not part of the path

    Salesforce record ID

    Yes. Determines all subfolders and filename

    Salesforce object/table name

    No

    Org ID

    No

    Backup date or job ID

    No

    Column Name

    1. The CopyStorm database column name for the column storing the field.

  • Type

    1. The Salesforce field type.

  • If “New Partition” was selected, a CREATE TABLE statement will be executed to create the new partition.
  • If a pre-existing partition was selected, an ALTER TABLE statement will be executed to add the selected fields to the target partition.

  • Copy field data from the source partition(s) to the target partition.

  • Update CopyStorm metadata for the selected fields.

  • DROP the data columns from the source partition(s).

  • Running the Partition Editor GUI

    A local folder on the CopyStorm server.
    An AWS S3 Bucket.

    Security Token

    Optional security token supplied by Salesforce.

    Alternate Host

    If your connection to Salesforce does not use one of the standard endpoint (login.salesforce.com or test.salesforce.com) then you must specify your endpoint as an alternate host. Example:

    • capstorm.my.salesforce.com

    Advanced Parameters

    Launch this dialog to set:

    • Proxy information

    • Password storage model

    • Secondary Salesforce connection parameters

    Number of seconds to wait for a response from Salesforce.

    Describe Batch Size

    Number of table descriptors to read from Salesforce in a single batch.

    Apache/HttpClient

    If checked then the Apache/HttpClient will be used to communicate with Salesforce instead of the technique built into the WSC library. It is unusual to need the Apache/HttpClient.

    Proxy Host

    Optional name or IP address of a proxy host

    Proxy Port

    Optional port on which a proxy host is listening.

    Proxy User

    Optional user name when a proxy requires it.

    Proxy Password

    Optional password when a proxy requires it.

    CopyStorm database username.

    Password

    CopyStorm database password.

    Schema

    Default schema to use. Note that this parameter is not supported by all databases.

    Snowflake
    JWT Configuration Reference
    SFDX Username Configuration Reference

    Number of records to process from Salesforce in a single batch. The default usually provides optimal performance.

    # Checker Threads

    Number of base 64 hyperlinks to analyze concurrently.

    Max Timeout (sec)

    Number seconds to allow for each hyperlink test. If a hyperlink HTTP request times out it is assumed to be OK based on Capstorm’s experience with problem records. Setting this to a smaller value may improve the overall throughput of the analysis.

    Report Timeouts

    If this option is checked then all HTTP timeouts will be reported as potential problems. Enabling this feature may be useful in selecting an optimal Max Timeout value for your organization.

    Main Tab

    Name

    Active

    Apply Policy

    Also Snapshot

    Days to Retain

    Filter Rule Type

    Filter Rule Parameters Tab

    Advanced Tab

    Advanced Retention Rules Editor
    Policy Filter Rules
    Policy Filter Rules

    #Read

    Number of records read from Salesforce.

    #Copied

    Number of records written to the database.

    #Skipped

    Records read but not copied as they are already in the backup.

    #Deleted

    Records removed from the database due to deletion in Salesforce beyond retention settings.

    #Per Minute

    Average number of records written to the database per minute.

    Total Time

    Total Elapsed time of the table.

    End

    Records read but not copied as they are already in the backup.

    #Deleted

    Records removed from the database due to deletion in Salesforce beyond retention settings.

    #Snapshot

    Records captured as part of point-in-time copy or custom snapshot.

    #Exceptions

    Number of exceptions reported during the job.

    Time

    Total elapsed time of the job.

    API Calls

    Number of Salesforce API calls used during the job.

    Version

    Application version used for the job.

    Config File

    Name of the .copyStormMedic configuration file associated with the job.

    Opens a dialog providing detailed status of the selected job.

    Id

    ID of the job.

    Status

    Completion status of the job. Green checkmark indicates this job had no exceptions. Red exclamation indicates job finished with at least one exception.

    Start

    The start timestamp of the job, in local time.

    End

    The end timestamp of the job, in local time.

    #Copied

    Number of records written to the database.

    #Skipped

    Records read but not copied as they are already in the backup.

    #Deleted

    Records removed from the database due to deletion in Salesforce beyond retention settings.

    #Snapshot

    Records captured as part of point-in-time copy or custom snapshot.

    #Exceptions

    Number of exceptions reported during the job.

    Time

    Total elapsed time of the job.

    API Calls

    Number of Salesforce API calls used during the job.

    Version

    Application version used for the job.

    Config File

    Name of the .copyStorm configuration file associated with the job.

    Table

    Opens a dialog providing detailed status of the selected job.

    Start Time

    Starting time of the table copy.

    End Time

    View...

    Opens a dialog providing detailed status of the selected job.

    Status

    Completion status of the job. Green checkmark indicates this job had no exceptions. Red exclamation indicates job finished with at least one exception.

    Start

    Individual Job View

    Individual Job View Table Headers

    Exceptions View

    CopyStorm/Medic Job History

    Job History Table Headers

    Individual Job View

    Other Features

    Ending time of the table copy.

    Start timestamp of the job.

    Feature Overview

    Step 1: Write a Java Class Implementing the Transformer

    Step 2: Register the Transformer with CopyStorm

    Step 3: Attach a Transformer to a CopyStorm Field

    My Transformer Does Not Work. What Should I Do?

    in this article
    package com.capstorm.extension;
    
    import org.apache.commons.lang3.StringUtils;
    import com.aslan.sfdc.extract.transform.ITransformer;
    
    public class ReverseTransformer implements ITransformer {
    
        /**
        * Take a string and return the string with the letters reversed.
        *
        *@param table - name of the Saleforce table containing the value
        *@param column - name of the Salesforce column containing the value
        *@param columnWidth - the number of characters in the column
        *@param recordId - the unique Saleforce record id containing the value
        *@param value - the values whose letters are to be reversed.
        *
        *@return the value with its letters reversed
        */
        @Override
        public String transform(String table, String column, int columnWidth, String recordId, String value) {
            if( null != value ) {
                value = StringUtils.reverse(value);
            }
            return value;
        }
    }
    <Transformers>
        <Transformer name="Reverse" class="com.capstorm.extension.ReverseTransformer" />
    </Transformers>
    <TableRule name="Contact">
        <FieldTransform name="LastName" transformer="Reverse" />
    </TableRule>

    Send Email To

    Yes

    Notification emails will be sent to this white space separated list of email addresses.

    Subject

    Yes

    The subject line used for notification emails. Though it can be any text you want, there are a few special text values that will be replaced dynamically before a message is sent:

    • “{status}” will be replaced by “OK” or “ERROR” based on the outcome of the job.

      • If there are any exceptions encountered then “ERROR” will be substituted, otherwise “OK” will be used.

    • “{application}” will be replaced by “CopyStorm/Medic”.

    Send Notification On

    No

    Determines when CopyStorm/Medic will send a notification email:

    • Success: If checked, an email will be sent if a job works perfectly (no exceptions).

    • Exception(s): If checked, an email will be sent if a job has any exception (including non-fatal exceptions where CopyStorm/Medic recovered).

    Require Encryption

    No

    If checked, CopyStorm/Medic will require that connections to the email server be encrypted with TLS.

    Email User

    No

    Username used to authenticate with the SMTP server.

    Email Password

    No

    Password used to authenticate with the SMTP server.

    Notification emails will be sent to this white space separated list of email addresses.

    Subject

    Yes

    The subject line used for notification emails. Though it can be any text you want, there are a few special text values that will be replaced dynamically before a message is sent:

    • “{status}” will be replaced by “OK” or “ERROR” based on the outcome of the job.

      • If there are any exceptions encountered then “ERROR” will be substituted, otherwise “OK” will be used.

    • “{application}” will be replaced by “CopyStorm/Medic”.

    • “{file}” will be replaced by the base name of the CopyStorm/Medic configuration file used by the job.

      • For example, the configuration file “C:\capstorm\config\myCopyStormMedicConfig.copyStormMedic” will be replaced with “myCopyStormMedicConfig.copyStormMedic”.

    Send Notification On

    No

    Determines when CopyStorm/Medic will send a notification email:

    • Success: If checked, an email will be sent if a job works perfectly (no exceptions).

    • Exception(s): If checked, an email will be sent if a job has any exception (including non-fatal exceptions where CopyStorm/Medic recovered).

    Notify Current User

    No

    If checked, the Salesforce User specified on the Main tab of CopyStorm/Medic will be notified in addition to the specified recipients (Send Email To).

    Email Host

    Yes

    The SMTP host used by your organization (used to send email). If you do not know this information ask your email administrator.

    Email From

    Yes

    SMTP Notifications

    The email address that will appear in the “From” field in sent notifications. Note that many email servers allow this value to be a fake email address (e.g. “noreply@capstorm.com”).

  • The log file is redirected to a text document named C:\users\Mary\LogFile.txt.

    • This is optional.

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

    Switch
    Parameter
    Description

    -sftype

    Sandbox

    Production

    -sfuser

    Snapshot policies can be executed from the command line without opening the CopyStorm UI. Use the -snapshot switch in place of -run:

    Windows:

    Linux/Mac:

    Switch
    Parameter
    Description

    -snapshot

    Policy Name

    Name of the snapshot policy to run.

    -snapshotThreads

    Count

    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

    configuration file
    CopyStorm.bat -run ../CopyStormDemo/DemoCredentials.copyStorm >c:/users/Mary/LogFile.txt
    sh CopyStorm.sh -run ../CopyStormDemo/DemoCredentials.copyStorm >/home/mary/LogFile.txt
    CopyStorm.bat -snapshot "My Snapshot Policy" -snapshotThreads 5 -snapshotSearchBatchSize 5000 -snapshotWriteBatchSize 5000 -snapshotScanRecordsFrom "2023-01-01" -snapshotScanRecordsThru "2024-01-01" >C:\logs\snapshot.txt
    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

    Command Line Reference

    Running a Snapshot Policy Headlessly

    CopyStorm Exit Codes

    Subject

    Yes

    The subject line used for notification emails. Though it can be any text you want, there are a few special text values that will be replaced dynamically before a message is sent:

    • “{status}” will be replaced by “OK” or “ERROR” based on the outcome of the job.

      • If there are any exceptions encountered then “ERROR” will be substituted, otherwise “OK” will be used.

    • “{file}” will be replaced by the base name of the CopyStorm configuration file used by the job.

    Send Notification On

    No

    Determines when CopyStorm will send a notification email:

    • Success: If checked, an email will be sent if a job works perfectly (no exceptions).

    • Exception(s): If checked, an email will be sent if a job has any exception (including non-fatal exceptions where CopyStorm recovered).

    Notify When Using GUI

    No

    If checked, email notifications will be sent when CopyStorm is launched from the GUI. If not checked, email notifications will only be sent when CopyStorm runs in batch mode.

    Notify Current User

    No

    If checked, the Salesforce User specified on the Main tab of CopyStorm will be notified in addition to the specified recipients (Send Email To).

    Parameter Name
    Required
    Description

    Email Host

    Yes

    The SMTP host used by your organization (used to send email). If you do not know this information ask your email administrator.

    Email From

    Yes

    The “Test Email Delivery” button causes an email to be sent to the recipient list. If communication to the SMTP email server or target Salesforce org is successful an acknowledgement dialog will be displayed and an email will be delivered to the recipients.

    If communication to the SMTP email server or target Salesforce org fails, a dialog will be displayed showing the error. In this case you should show the error to your local administrator.

    Test email notification:

    Under normal circumstances CopyStorm will deliver a notification email that looks like the following. Note that this data is also stored in the CopyStorm database and can be browsed using CopyStorm/Medic (or any other tool you choose).

    If CopyStorm encountered an error during the backup job, errors will be listed below this summary table:

    If CopyStorm fails before any backup can be attempted, a notification email like the following will be sent. In this example the password for Salesforce was incorrect in the CopyStorm configuration file.

    Send Email To

    Yes

    SFDC Notifications

    Notification emails will be sent to this white space separated list of email addresses.

    SMTP Notifications

    How to Test Email Delivery

    CopyStorm Notification Reports

    How to Set Table Specific Processing Options

    There are a number of rare cases in which table-specific processing rules are necessary (please remember, these are rare cases):

    • The Salesforce metadata API reports fields in a table that are not actually present.

    • The default LIMIT option for a table always times out.

    • The Salesforce SOAP API returns an invalid response for an Attachment while the REST API works properly.

    In all cases CopyStorm supports overriding default processing rules for a table by creating an XML configuration file “TableRuleRegistry.xml” in a CopyStorm configuration directory. The best practice for creating a configuration directory is to:

    • Create a “config” subdirectory in the directory where .copyStorm files are kept.

      • This directory should not be inside the CopyStorm installation directory.

    • Set the “Config Directory” parameter on the CopyStorm Configuration tab in the External Configuration section to point to the newly created config directory.

    • Store the “TableRuleRegistry.xml” configuration file in the newly created config directory.

    For other best practices on how to install CopyStorm and your configuration files, please see our article.

    A quick and dirty solution is to store custom configurations in a subdirectory named “config” in the CopyStorm installation director, but this makes upgrading the CopyStorm installation more difficult:

    • If CopyStorm.bat is in the directory “C:\bin\CopyStorm”

    • Create a file named “C:\bin\CopyStorm\config\TableRuleRegistry.xml”

    The following TableRuleRegistry.xml file will cause CopyStorm to exclude Attachment and ContentVersion records where their data size is greater than 1,000,000 bytes:

    The following TableRuleRegistry.xml file will cause CopyStorm to exclude the LastViewedDate and LastReferencedDate fields when processing the Salesforce Opportunity table (columns will be created in the database but never populated):

    The following TableRuleRegistry.xml file will cause CopyStorm to exclude all fields called “LastViewedDate” from tables in the “XYZ” package (columns will be created in the database but never populated):

    The following TableRuleRegistry.xml file will cause CopyStorm to only include the “Name” field when processing the Salesforce Opportunity table (other columns will be created in the database but never populated):

    Note that:

    • When an IncludeField is specified any ExcludeField rules are ignored.

    • The following fields are always copied, even if they are in a configuration directive:

      • SystemModStamp

      • CreatedDate

    Default CopyStorm behavior is to backup formula columns just like any other column. To change this behavior, the “excludeFormulas” directive will cause CopyStorm to ignore formulas on a table. Note that the database columns corresponding to Salesforce formulas will still be created but will always have null values.

    The following TableRuleRegistry.xml file will cause CopyStorm to exclude formulas for the Opportunity table.

    Starting with CopyStorm version 8.37.1 the default formula exclusion rule can be set for all tables by setting the “excludeFormulas” attribute on the table “default”. The “default” table does not correspond with a table name in Salesforce or the CopyStorm database, but is used to specify global table processing options.

    The following TableRuleRegistry.xml file will cause CopyStorm to exclude formulas for all tables (unless there is a rule overriding the global default for individual tables):

    The following TableRuleRegistry.xml file will cause CopyStorm to read Opportunity records 17,777 at a time:

    Default CopyStorm behavior is to use the systemmodstamp field to determine when a record has been modified. This ensures that all changes are mimicked in CopyStorm, but occasionally a site will want to use the LastModifiedDate column instead.

    The following TableRuleRegistry.xml file will cause CopyStorm to use the “LastModifiedDate” column to determine if “Account” records have changed:

    Since this would be tedious to apply to all tables, another option is to change the global default for all tables. Note that if a table does not have the specified timestamp column, CopyStorm will automatically adjust to the most pertinent column contained in the table.

    The following TableRuleRegistry.xml file will cause CopyStorm to use the “LastModifiedDate” to determine if any record has changed:

    Default CopyStorm behavior is to create database tables with names matching the corresponding table in Salesforce. To override the database name for a specific Salesforce table, use the “databaseTableName” parameter.

    The following TableRuleRegistry.xml file will cause CopyStorm to store “Account” records in a table named “AccountMaster”:

    Default CopyStorm behavior is to use the default RDBMS options. To specify non-default options for table creation use the “CreateTableRule” configuration directive.

    The following TableRuleRegistry.xml file will cause CopyStorm to use specific creation options in MySQL and SQL/Server:

    If the database type matches the “database” parameter the specified option will be appended to the generated CREATE TABLE statement. For example:

    CREATE TABLE Account(id CHAR(18) PRIMARY KEY, name NVARCHAR(80) NULL, …) ENGINE=ISAM;

    To apply a rule to all tables, set the “name” of the TableRule to “default”.

    Default CopyStorm behavior is to process each table until all records are backed up. Setting the “maxRuntime” parameter will cause CopyStorm to stop processing a table after an amount of time has elapsed. The maxRuntime is specified in seconds.

    The following TableRuleRegistry.xml file will cause CopyStorm to stop processing Attachment records and continue with the next table in the backup set after 10 minutes has elapsed:

    Default CopyStorm behavior is for all table to use the Bulk API parameters specified on the CopyStorm Advanced tab. Several of these parameters can be overridden on a per-table basis.

    The following TableRuleRegistry.xml file will cause CopyStorm to use table-specific Bulk API rules for the Account table:

    • Switch to the Bulk API after 5000 records have been processed by the SOAP API.

    • Read 100,000 records per Bulk API transaction.

    The following TableRuleRegistry.xml file will cause CopyStorm to always use the REST API for the Attachment table:

    Default CopyStorm behavior is to use the same record deletion policy on all tables, specified by the “Delete Older Than” option on the Advanced tab.

    The following TableRuleRegistry.xml file will cause CopyStorm to never remove deleted records from the Attachment table (overriding the “Delete Older Than” global parameter):

    Default CopyStorm behavior is to back up all columns in timestamp order. For rare cases where a table does not contain a timestamp column, a table can be forced to backup in ID order. In nearly all cases, this option is only used internally by CopyStorm for Salesforce system tables that do not follow the normal rules.

    The following TableRuleRegistry.xml file will cause CopyStorm to backup the PartnerNetworkRecordConnection table by ID (this is an example of a Salesforce system table that cannot be backed up in timestamp order):

    The following TableRuleRegistry.xml file will cause CopyStorm to delete all data in the “PartnerNetworkRecordConnection” before starting each copy:

    A number of tables in Salesforce do not support sorting by their timestamp column, and other tables where a user without the ViewAllData permission will get stuck. In these extremely rare cases, CopyStorm can be forced to backup a table using a sliding timebox approach.

    The following TableRuleRegistry.xml file will cause CopyStorm to backup the LoginEvent table using a sliding timebox on the EventDate field:

    This XML rule means:

    Use a sliding 90 day window when backing up LoginEvent. Start the first search on 1-Jan-2014 or the most recent EventDate in the LoginEvent backup table.

    The system will backup LoginEvent entries in roughly the following order:

    1-Jan-2014 to 31-Mar-2014 1-Apr-2014 to 30-Jun-2014 1-Jul-2014 to 30-Sep-2014 etc… until the current date is reached.

    Subsequent backups will start the first timebox at the most recent EventDate in the LoginEvent backup table.

    A single TableRuleRegistry.xml file can contain multiple rules and any or all features can be specified for a specific table.

    However, this is a bad practice unless instructed to by Capstorm. The built-in rules have been validated on many Salesforce instances and are generally optimal.

    How to Override Salesforce Field Definitions

    Copystorm creates database columns using metadata provided by Salesforce to determine the proper database column type. Salesforce metadata is usually correct, but in the rare occasion that it is wrong or inconsistent CopyStorm provides a way to override the column type. This article describes how to configure CopyStorm to override the column definition provided by Salesforce (or even ignore a Salesforce column completely).

    • If Salesforce says a column is 80 characters long, CopyStorm will create a NVARCHAR(80) column in the target database.

    • If Salesforce says a column is a single digit number, CopyStorm will create a DECIMAL(1,0) column in the target database.

    Unfortunately, sometimes data provided by Salesforce does not match the column definition. For example, Salesforce claims that multipicklist columns may contain up to 4099 UTF-8 characters. Though this is true in fact, it would be rare for a Salesforce instance to have a value this long. For searching, indexing, and data storage purposes a CopyStorm instance may override Salesforce’s 4099 value with a much smaller data type.

    Base64 Export

    When storing Files and Attachments in the CopyStorm database, CopyStorm mirrors the Salesforce API specification for the field. This means that Salesforce object fields of type Base64 (such as Attachment.Body and ContentVersion.VersionData fields) are stored in the CopyStorm database as Base64 text strings. Such representations are industry standard and are intended to eliminate problems that can arise with storing binary values in a database. CopyStorm also removes limitations on the size of large text fields by means of a process of “chunking” – breaking down large blocks of content into chunks that fit comfortably in database given the unique datamodel limitations of the database engine. For example – Salesforce supports ContentVersion files as large as 2 GB, but the largest text string that can be stored in a PostgreSQL database is approximately 1 GB. With the “chunking” system, there are no practical limitations to how large a field value can be stored.

    This storage format can make it complex to view the contents of a Salesforce File or Attachment. For example, if the Base64 content is a PDF file, then you cannot view the PDF using a normal PDF viewer without exporting the Base64 text from the database and decoding the file content.

    The Base64 Export tool provides a way to directly export Files and Attachments from the CopyStorm database. This tool is also compatible with all database storage types used by CopyStorm – Base64 strings, chunked files, and CS:Govern-encrypted files. Just as there are no practical limits in how large a document can be stored in the primary CopyStorm database or a Snapshot, there are also no practical limits on how large a document can be exported to the file system (as long as you have enough disk to store the file!).

    To run the Base64 Export tool in the CopyStorm/Medic GUI, open the tool from the main menu using Other Tools => Data Synchronization => Export Base64 Objects to File System. This will open the following GUI:

    “{file}” will be replaced by the base name of the CopyStorm/Medic configuration file used by the job.

    • For example, the configuration file “C:\capstorm\config\myCopyStormMedicConfig.copyStormMedic” will be replaced with “myCopyStormMedicConfig.copyStormMedic”.

    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)

    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)

    For example, the configuration file “C:\capstorm\config\myCopyStormConfig.copyStorm” will be replaced with “myCopyStormConfig.copyStorm”.

    The email address that will appear in the “From” field in sent notifications. Note that many email servers allow this value to be a fake email address (e.g. “noreply@capstorm.com”).

    Send Email To

    Yes

    Notification emails will be sent to this white space separated list of email addresses.

    Subject

    Yes

    The subject line used for notification emails. Though it can be any text you want, there are a few special text values that will be replaced dynamically before a message is sent:

    • “{status}” will be replaced by “OK” or “ERROR” based on the outcome of the job.

      • If there are any exceptions encountered then “ERROR” will be substituted, otherwise “OK” will be used.

    • “{file}” will be replaced by the base name of the CopyStorm configuration file used by the job.

      • For example, the configuration file “C:\capstorm\config\myCopyStormConfig.copyStorm” will be replaced with “myCopyStormConfig.copyStorm”.

    Send Notification On

    No

    Determines when CopyStorm will send a notification email:

    • Success: If checked, an email will be sent if a job works perfectly (no exceptions).

    • Exception(s): If checked, an email will be sent if a job has any exception (including non-fatal exceptions where CopyStorm recovered).

    Notify When Using GUI

    No

    If checked, email notifications will be sent when CopyStorm is launched from the GUI. If not checked, email notifications will only be sent when CopyStorm runs in batch mode.

    Require Encryption

    No

    If checked, CopyStorm will require that connections to the email server be encrypted with TLS.

    Email Report Format

    Yes

    A list of supported formats for the notification email.

    Email User

    No

    Username used to authenticate with the SMTP server.

    Email Password

    No

    Password used to authenticate with the SMTP server.

    LastModifiedDate

  • LoginTime

  • isDeleted

  • Task: Prevent Large Attachments from being extracted from Salesforce

    Task: Prevent fields from being extracted from Salesforce

    Task: Specify exactly which fields are extracted from Salesforce

    Task: Exclude Formulas from CopyStorm tables

    Task: Change the default SOQL LIMIT value used for a table when reading from Salesforce

    Task: Change the Field used to determine if a record has been modified

    Task: Force CopyStorm to use a specific database table name

    Task: Add database specific table creation options

    Task: Limit the amount of time CopyStorm will spend on a table

    Task: Set table specific BULK API processing parameters

    Task: Force the REST API to be used for a table

    Task: Change the Record Deletion Policy for a table

    Task: Force a table to backup by ID Order

    Task: Force a table to be TRUNCATED before each copy

    Task: Force a table to backup using a Timebox Window

    Summary

    Installation Best Practices
    <TableRules>
        <TableRule name="Attachment"  predicate="bodyLength&lt;1000000" />
        <TableRule name="ContentVersion"  predicate="contentSize&lt;1000000" />
    </TableRules>
    <TableRules>
        <TableRule name="Opportunity" >
            <ExcludeField name="LastViewedDate" />
            <ExcludeField name="LastReferencedDate" />
        </TableRule>
    </TableRules>
    <TableRules>
        <TableRule regexp="XYZ__.*" >
            <ExcludeField name="LastViewedDate" />
        </TableRule>
    </TableRules>
    <TableRules>
        <TableRule name="Opportunity" >
            <IncludeField name="Name" />
        </TableRule>
    </TableRules>
    <TableRules>
        <TableRule name="Opportunity" excludeFormulas="true" />
    </TableRules>
    <TableRules>
        <TableRule name="default" excludeFormulas="true" />
    </TableRules>
    <TableRules>
        <TableRule name="Opportunity" limit="17777" />
    </TableRules>
    <TableRules>
        <TableRule name="Account" timestamp="LastModifiedDate" />
    </TableRules>
    <TableRules>
        <TableRule name="default" timestamp="LastModifiedDate" />
    </TableRules>
    <TableRules>
        <TableRule name="Account" databaseTableName="AccountMaster" />
    </TableRules>
    <TableRules>
        <TableRule name="default" >
            <CreateTableRule database="MySQL" option="ENGINE=ISAM"/>
            <CreateTableRule database="SQLServer" option="WITH(DATA_COMPRESSION=PAGE)"/>
        </TableRule>
    </TableRules>
    <TableRules>
        <TableRule name="Attachment" maxRuntime="600" />
    <TableRules/>
    <TableRules>
        <TableRule name="Account" bulkThreshold="5000" bulkLimit="100000" />
    <TableRules/>
    <TableRules>
        <TableRule name="Attachment" useRestAPI="true" />
    <TableRules/>
    <TableRules>
        <TableRule name="Attachment" purgeDays="" />
    <TableRules/>
    <TableRules>
        <TableRule name="PartnerNetworkRecordConnection" ignoreTimestamp="true" />
    <TableRules/>
    <TableRules>
        <TableRule name="PartnerNetworkRecordConnection" truncate="true" />
    <TableRules/>
    <TableRules>
        <TableRule name="LoginEvent"  timestamp="EventDate" timebox="90" timeboxEpoch="2014-01-01" />
    <TableRules/>

    Sometimes Salesforce metadata is wrong when determining column size — for example, an aggregate column that says it is 80 characters wide may have much wider values when table data is queried (CopyStorm deals with this case automatically).

    In all cases, Salesforce metadata can be overridden by including an ExtractionManagerConfig.xml configuration file. The configuration file can be located in:

    • The configuration directory referenced by the .copyStorm configuration file.

    • The directory “config” in the CopyStorm installation directory.

    It is also possible to force CopyStorm to completely ignore a field using directives in an ExtractionManagerConfig.xml file. See the end of this article for details.

    The only tricky part of this configuration is that table and column names must precisely match the definitions in Salesforce (names are case sensitive).

    There is no limit to the number of FieldOverride directives. New and changed directives will be applied to existing columns in the target database the next time CopyStorm runs.

    Option Name
    Value Type
    Description

    table

    string

    Salesforce table to which the override applies. This option is case sensitive.

    column

    string

    The extraPrecisionattribute overrides how many additional precision and scale digits CopyStorm adds to a numeric field when Strict Decimal Mode is NOT enabled.

    **Example:**If a field override such as the below override is provided, the resulting column definition in the database would be “AccountRevenue__c decimal(22,6)” — 18 + 4 precision, 2 + 4 scale.

    • If extraPrecision is defined for a field, it overrides the system-wide Extra Scale setting for the specified field.

    • When using extraPrecision, the total precision for a field must NOT exceed the database limit of 38.

    • extraPrecision is ignored when Strict Decimal Modeis enabled.

    A configuration like the following will cause all multipicklist type columns in CopyStorm to be 120 characters wide (rather than the Salesforce default of 4099):

    The tables being overridden can be specified by including an optional “table” parameter. In the following example the Contact table multipicklist columns will be 80 characters, with other tables using 120 characters:

    A configuration file like the following will cause all string formula type columns in CopyStorm to be 255 characters wide (rather than the Salesforce default of 1300):

    The table being overridden can be specified using an optional “table” parameter. In the following example the Contact table string formula columns will be 80 characters with other tables being limited to 120 characters:

    If Salesforce has a single digit numeric column (e.g. DECIMAL(1)) and an aggregate column SUMs this column, Salesforce will sometimes declare the SUM column with a DECIMAL(1) type. This causes problems when a SUM() is greater than or equal to 10 — without an override CopyStorm will read Salesforce metadata, create a DECIMAL(1) column, and report a “value too large” error when attempting to insert records where the SUM() value is too large.

    This configuration will alter the precision of the “AnnualRevenue” column for the “Account” object from DECIMAL(18,0) to DECIMAL(18,3):

    This configuration will alter the custom decimal field “MonthlyRevenue__c” column for the “Account” object to DECIMAL(24, 4):

    This example increases the length of the Account.Name database column from 80 to 120 and the Account.Description column to 200:

    • Use digits for fields that store whole numbers (integers). This maps closely to how Salesforce defines numeric length for non-decimal types.

    • Use precision for decimal or floating-point fields. This ensures the appropriate structure is generated in the target database.

    There is different behavior for the creation of numeric fields in the CopyStorm database depending on if the Use Strict DECIMALs configuration parameter is utilized. For more information on this option, see here.

    • Strict Decimal Mode: CopyStorm will create or update numeric fields in the database using the exact precision and scale as provided by Salesforce.

    • Non-Strict Decimal Mode: CopyStorm will create or update numeric fields in the database with additional precision as denoted by the Extra Precision field on the Database Schema section of the Configuration tab (By default this value is set to 2).

    The behavior of precision and scale can vary depending on the target database. Here is a quick breakdown:

    Database Type
    Strict Decimal Mode
    Non-Strict Decimal Mode

    SQL Server

    Uses the specified precision and scale

    Adds the specified extra digits and ensures a minimum total width of 19 digits

    H2

    Uses the specified precision and scale

    Sometimes, but rarely, a company desires to completely ignore Salesforce columns and not transfer them or their data into the CopyStorm backup. Most of this time this comes up during a migration where backing up fields associated with an obsolete managed package is desired.

    Here are a few examples of how to completely ignore fields.

    • The first IgnoreField directive ignores the field Account.MyCustomField__c

    • The second IgnoreField directive ignores all columns added by the Salesforce CPQ package. Note that the special table name default means to apply this rule all tables.

    Be careful! An IgnoreField directive tells CopyStorm to pretend that a column no longer exists in Salesforce and, by default, when a column no longer exists in Salesforce it will be dropped in the CopyStorm database.

    The options for the IgnoreField directive are:

    • table — name of the Salesforce table containing the field(s). The special name default means that the rule will apply to all tables.

    • name — a regular expression indicating which columns should be ignored. Of course, just a column name also works since this is simple regular expression.

    Note that this feature was added in CopyStorm 9.47.1. Earlier CopyStorm versions will silently ignore IgnoreField directives.

    Background

    <ExtractionManager>
    	<FieldOverride table="Account" column="AccountRevenue__c" precision="18" scale="2" extraPrecision="4" />
    </ExtractionManager>
    <ExtractionManager>
        <FieldTypeOverride fieldType="multipicklist" length="120" />
    </ExtractionManager>
    <ExtractionManager>
        <FieldTypeOverride fieldType="multipicklist" length="120" />
        <FieldTypeOverride fieldType="multipicklist" table="Contact" length="80" />
    </ExtractionManager>
    <ExtractionManager>
        <FormulaTypeOverride type="string" length="255" />
    </ExtractionManager>
    <ExtractionManager>
        <FormulaTypeOverride type="string" length="120" />
        <FormulaTypeOverride type="string" table="Contact" length="80" />
    </ExtractionManager>
    <ExtractionManager>
        <FieldOverride table="Account" column="AnnualRevenue" digits="18" scale="3" />
    </ExtractionManager>
    <ExtractionManager>
    	<FieldOverride table="Account" column="MonthlyRevenue__c" precision="24" scale="4" />
    </ExtractionManager>
    <ExtractionManager>
        <FieldOverride table="Account" column="Name" length="120" />
        <FieldOverride table="Account" column="Description" length="200" />
    </ExtractionManager>
    <ExtractionManager>
        <IgnoreField table="Account" name="MyCustomField__c"  />
        <IgnoreField table="default" name="SBQQ__.*" />
    </ExtractionManager>

    FieldOverride Options

    About extraPrecision

    Important Notes:

    Problem: Multipicklist Columns Are Too Wide

    Problem: String Formulas Are Too Wide

    Problem: Salesforce Lies About Column Length

    Fixing Salesforce Metadata Inconsistencies

    Digits vs. Precision: When to Use Each

    Strict Decimal Mode Behavior

    What to Expect by Database

    Problem: Completely Ignore Salesforce Columns

    The DataSet Selector drop-down box in the top-left of this tool contains a listing that includes the primary CopyStorm Database along with any defined Snapshot policies that the user has defined. In the diagram above, the primary CopyStorm Database has been selected which means that the Base64 Exporter will export files stored in the main CopyStorm data tables.

    Below that drop-down box is the list of Available Table Fields. The Available Table Fields list allows selection of the specific File or Attachment object and field(s) to be exported.

    When exporting content out of the source DataSet and into the file system, the tool, minimally, must know where to place those exported files. CopyStorm/Medic creates the output location by combining the “Output Path” folder path and a rule that specifies which sub-folders, if any, the files should be exported into. The Output Path setting is shown in the GUI screen shot above, and the sub-folder rule is provided by the Folder Names drop-down box. This drop-down has two choices:

    • No Sub-Folders: Files are exported into a flat structure in the Output Path folder location.

    • ObjectType: Files are exported into a folder whose name is based upon the Salesforce object name. For example, all ContentVersion documents will be exported into a folder named [Output Path]/ContentVersion/.

    As not all File objects in Salesforce provide a file name field, the Default File Extension is used to provide a reasonable default value to use in cases where a file name cannot be established.

    The Decrypt Compliance Data checkbox is used to tell the Base64 Export tool whether it should attempt to decrypt a Base64 field that has been encrypted with CS:Govern. If the field is encrypted with CS:Govern, then this checkbox will cause CopyStorm/Medic to attempt to decrypt the field values – if you have permission to view the plaintext for the fields, then it will export the file data. If you do not have permission to view the plaintext, CopyStorm/Medic will export the CS:Govern masked value.

    To configure rules for exporting files from a specific field, click on the field name in the left-hand side of the Base64 Exporter. This will display a dialog that looks like the following:

    This dialog allows configuration of a number of parameters, selecting which records should be exported along with setting restrictions to limit the total disk consumption used by the exporter. The Base64 Export tool allows limits on both the number of files to be exported as well as the total disk space taken up by the export process. It is important to know that these limits are per-object based. For example, if you enter 5 into the Max Exported Files field for the Attachment object along with a value of 15 for the ContentVersion object, and there are more than five Attachment and more than 15 ContentVersion records that match the selection parameters, then 20 total files will be written. There will be 5 Attachment files written to the disk, and 15 ContentVersion records similarly written.

    A blank value for the Max Exported Files sets there to be no limit – ALL scanned candidate records will be exported for all objects and records matching the selection criteria. This is also true for the Max Disk Space Consumption parameter – if this parameter is set to blank, then CopyStorm/Medic will not limit the amount of disk used by the export.

    Having values entered for BOTH the Max Exported Files as well as the Max Disk Space Consumption data entry fields causes both rules to be applied – whichever limit is exceeded first will stop the processing of the object type.

    Having limits on the Max Exported Files as well as the Max Disk Space Consumption helps you prevent runaway situations where millions of files or terabytes of data match the criteria – filling up all space on the output drive. You can also play with the tool with a small number for one or the other (or both) and, once comfortable with how it works, leave those data entry fields blank to allow for a complete export.

    The Base64 Export tool will use the following logic to determine the name of the file to be exported to the file system:

    1. First the tool will look for a title field in the scanned candidate record. If the title field is not blank, then the title field value will be used. If there is no title field or the title field is blank, the SalesforceId will be used as the file name.

    2. If the selection for the File Names drop-down box is PreserveFileName then we are done and we know the name of the file to be exported – it is the one from step (1).

    3. If the selection for the File Names drop-down box is ID_Filename and a title field value was found in step (1), the file name will be the Salesforce record Id followed by an underscore and followed by the title found in step (1). Otherwise the filename is just the Salesforce Id.

    4. If the selection for the File Names drop-down box is Object_ID_Filename and a non-blank title was found in step (1) then the file name will be the Salesforce record’s Object name followed by an underscore and then followed by the Salesforce record Id followed by an underscore and followed by the title found in step (1). Otherwise it will be the Salesforce record Object name followed by an underscore and then followed by the Salesforce record Id.

    If exporting files to a directory that already has files in it, then CopyStorm/Medic may create new output files and not overwrite existing files, or CopyStorm/Medic may overwrite the existing files with a new export.

    These rules also apply to exports that may include duplicate file names – for example:

    • Files were exported to the target folder from an earlier CopyStorm/Medic session.

    • A target Output Path was selected which just happened to already contain some files some of which some just happened to have the same name as files to be exported.

    • The user clicks the Export button multiple times – each click causing the tool to re-scan and re-export candidate records.

    • The user has selected the No Sub-Folders option for the Folder Names drop-down box and there happen to be similarly titled documents in Salesforce even though the Object types are different. For example, there might be an Attachment called “Company Regulations.pdf” as well as a ContentVersion object with that exact same name.

    The Duplicate Rule drop-down box is used to configure the Base64 Export tool to handle these situations. Here are the options:

    • Skip: If the tool attempts to write a file to the file system that already exists in the target folder, it will simply skip exporting that file (in other words it will not clobber the existing file.)

    • Overwrite: If the tool attempts to write a file to the file system that already exists in the target folder, it will simply overwrite that file (in other words it will clobber the existing file.)

    • Version: If the tool attempts to write a file to the file system that already exists in the target folder it will suffix the new file with the conventional syntax for such cases – a space followed by parentheses that enclose a monotonically increasing number. Behind the scenes the tool will continuously bump that number until a unique file name is generated.

    Next to the File Rules tab in the screen shot above of the Base64 Export Rules dialog, there is a tab called Select Records. Clicking on that tab will show a view that looks like this:

    Like the File Rules, the Select Records tab defines rules that are specific to the selected Object from the Available Table Fields list. These rules, however, have nothing to do with how and where files are stored in the target file system. Instead they are used to determine which records in the selected DataSet are candidates for export. This is a much more strategic and surgical rule than the file rules, and the functionality provides similar options as in the CopyStorm/Restore application. For details, see the Records to Restore Editor documentation in the CopyStorm/Restore section.

    Note that not all of the UI elements used in the dialogs for Restore apply to Base64 Export.

    Beyond selecting which records should be exported, the Base64 Exporter also allows point-in-time selection of matching records. The following screen shot shows available options for Point-In-Time Export. These are available when a Snapshot is selected in the DataSet Selector:

    When selecting a Snapshot from the DataSet Selector, you have options for determining which points in time the Base64 field values should be exported from. The screen shot above is showing the A Point In Time selection. Here are the available choices:

    • Most Recent

    • A Point In Time

    • A Single Date

    • Between Two Times

    An in-depth discussion of how the CapStorm Snapshot sub-system works can be found here (How do CopyStorm Archives Work).

    The following shows available options when the Most Recent selection is made:

    The following screen shot shows available options when the A Single Date selection is made:

    The following screen shot shows available options when the Between Two Times selection is made:

    If either of the following options are selected, it is possible that multiple files match the selection criteria:

    • A Single Date: The time span starts at midnight of the selected date and ends just prior to midnight of the following day – resulting in a 24 hour period.

    • Between Two Times: The time span starts at the specified start time and ends at the specified end time.

    In those two cases it is very possible that there are many records for the selected Salesforce object of a specified Salesforce Id. To choose which version(s) of the record to export, you can select the Earliest, the Latest, or All, versions of that Salesforce Id.

    Available tables are provided by a Base64ExportTableRuleRegistry.xml configuration file. This file contains metadata that defines which Salesforce object fields are candidates for the Base64 Export process, and contains the following built-in definitions.

    To add a new table to the Base64 Exporter, create a new Base64ExportTableRuleRegistry.xml file and add it to the [CopyStormMedic]/config/ directory.

    Each rule in this XML document specifies the following:

    • The name of the Salesforce object (tableName)

    • The name of the Salesforce Base64 field (contentsFieldName)

    • The name of the Salesforce field whose value is the title of the document (titleFieldName)

    • The name of the Salesforce field whose value is the length (in bytes) of the document (contentLengthFieldName)

    All attributes are required with the exception of the titleFieldName attribute. If the titleFieldName attribute is not provided, the Salesforce Id field value will be used to name the exported files.

    The Base64 Export tool cannot be executed as a batch job.

    Running Base64 Export in a GUI

    Base64 Export Parameters

    File Rules

    File Name and Duplicate (Clobbering) Rules

    Record Selector Rules

    Point-In-Time Export From Snapshot

    Adding a Field to the Base64 Exporter

    Running Base64 Export as a Batch Job

    CopyStorm/View

    Welcome to the CopyStorm/View Learning Center.

    In this area you will find articles explaining how to quickly create a database combining one or more tables from multiple CopyStorm backups.

    CopyStorm/View builds SQL which combines tables from multiple CopyStorm backups into a new database built from database views.

    For example:

    • Suppose an organization has three divisions: Americas, Europe, and South America. Each division has its own Salesforce instance, using CopyStorm for backups.

    Salesforce column to which the override applies. This option is case sensitive.

    length

    integer

    Number of characters for a string column. This option only applies to string type columns.

    digits

    integer

    Total number of digits for a numeric column (utilized for integers).

    precision

    integer

    Total number of digits for a numeric column (utilized for decimals).

    scale

    integer

    Number of digits after the decimal point for a numeric column.

    extraPrecision

    integer

    Overrides the Extra Precision added to a numeric column for the specified field.

    htmlFormatted

    boolean

    Overrides the Salesforce field definition to denote the field is HTML formatted.

    Adds the specified extra digits and ensures a minimum total width of 20 digits

    Oracle

    Uses the specified precision and scale as NUMBER(precision, scale)

    Utilizes the generic NUMBER datatype without enforced limits

    PostgreSQL

    Uses the specified precision and scale

    Same behavior as Strict Decimal Mode

    Redshift

    Uses the specified precision and scale as NUMERIC(precision, scale)

    Adds the specified extra digits and ensures a minimum total width of 19 digits

    Snowflake

    Uses the specified precision and scale

    Adds the specified extra digits and ensures a minimum total width of 19 digits

    MySQL

    Uses the specified precision and scale

    Adds the specified extra digits and ensures a minimum total width of 20 digits

    The CEO is asking for daily reports on opportunity generation and wants to see it across all divisions.

    CopyStorm/View helps solve this problem by creating a single database including data from all three divisions by creating views for selected tables that look like:

    CREATE VIEW Opportunity( CopStormDatabase, Id, Name, …) AS SELECT ‘Americas’, Id, Name, … FROM AmericasBackup UNION ALL SELECT ‘Europe’, Id, Name, … FROM EuropeAmericasBackup UNION ALL SELECT ‘SouthAmerica’, Id, Name, … FROM SouthAmericaAmericasBackup

    This makes finding the answer for the CEO as simple as:

    SELECT CopyStormDatabase AS Division, Name, Amount WHERE CreatedDate >= TODAY

    Overview

    CopyStorm/Medic

    CopyStorm/Medic is a collection of tools for maintaining, validating, and repairing a CopyStorm database. CopyStorm/Medic can be downloaded from www.capstorm.com.

    Tools provided with CopyStorm/Medic include:

    Tool
    Tool Name
    Tool Path
    Description

    CopyStorm/Medic can be started as a graphical application by running CopyStormMedic.bat (or “sh CopyStormMedic.sh” on Linux). The UI mode is often the only way a site will use the tool, but it can also run as a batch job (details later in this article).

    The CopyStorm/Medic UI is subdivided into several tabs — the Main tab contains Salesforce and CopyStorm connection credentials and other tabs contain individual CopyStorm/Medic tools. Like other Capstorm applications, a CopyStorm/Medic configuration can be saved/restored to/from an encrypted text file. Saved CopyStorm/Medic configuration files can be used to run CopyStorm/Medic as a batch job.

    After saving a CopyStorm/Medic configuration file, it can be used to launch CopyStorm/Medic in batch mode.

    The syntax for starting CopyStorm/Medic in batch mode is:

    • Windows: “CopyStormMedic.bat -tool ToolName -run configFile.CopyStormMedic”

    • Linux: “sh CopyStormMedic.sh -tool ToolName -run configFile.CopyStormMedic”

    The value for ToolName must be selected from the table at the beginning of this article. For example, to run the Fix isDeleted tool on Windows:

    • CopyStormMedic.bat -tool fixDeleted -run configFile.copyStormMedic

    Switch
    Parameter
    Description

    Other Tools

    CopyStorm includes a number of useful tools that can be found under the “Tools” menu in the top-left corner of the application GUI.

    The following tools are included:

    • SOQL Query Tool (Salesforce)

    • SQL Query Tool (Database)

    • Skipped Record Log Explorer

    The SOQL Query Tool provides a convenient, in-app interface for running SOQL queries against the target Salesforce org specified on the left side of the “Main” tab of CopyStorm. To use this tool, CopyStorm must connect to Salesforce, so the Salesforce credentials specified must be valid (use the “Test Salesforce Connection” button to validate).

    To use the tool, simply enter a valid SOQL query into the white text-area and click the “Execute SOQL” button. You can choose to either include or exclude Deleted and Archived records in the results with the “Include Deleted And Archived Records” checkbox. The results of the query will be displayed below.

    The SQL Query Tool provides a convenient, in-app interface for running SQL queries against the target database specified on the right side of the “Main” tab of CopyStorm. To use this tool, CopyStorm must connect to the database, so the database credentials specified must be valid (use the “Test Database Connection” button to validate).

    To use the tool, simply enter a valid SQL query into the white text-area and click the “Execute SQL” button. The results of the query will be displayed below.

    The Skipped Record Log Explorer provides a convenient interface for exploring and analyzing the reports recorded by CopyStorm when a record has been skipped during a job due to an error caused by the Salesforce platform. Errors that are reported by this feature include:

    • Base64ReadErrors (potential file body corruption)

    • DescribeSObjectErrors (potential metadata corruption).

    The top window of the interface contains a filterable search window for each skipped record, and the bottom window provides all details recorded by CopyStorm when the record was skipped:

    CopyStorm Dashboard

    The Salesforce Job Logging subsystem allows CopyStorm to log job information to the Salesforce CopyStorm Dashboard. This information includes job status, progress, and history.

    The information that is logged is the same information that can be found in the . The package that must be deployed to Salesforce as part of the process includes 3 custom objects, a Permission Set, a Lightning application, a dashboard, and some sample/starter reports. The custom objects and the Permission Set are required for the Salesforce Job Logging subsystem to function. The out-of-the-box fields of the custom objects should be treated as read-only, but additional customization is welcomed.

    • Custom Objects

      • CopyStorm Job

    SOQL Query Tool (Salesforce)

    SQL Query Tool (Database)

    Skipped Record Log Explorer

    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

    -apiTraceFile

    filename

    Write the entire conversation with the Salesforce API to a file (the file may be huge).

    Log Manager

    Other Tools →Log Manager

    View, manage, and export the status of a historical CopyStorm run.

    Fix IsDeleted

    fixDeleted

    Other Tools →Data Synchronization →Fix Deleted

    If a record is deleted in Salesforce and the Salesforce recycle bin entry is cleared before CopyStorm runs, CopyStorm will not know that the Salesforce record has been deleted. The Fix IsDeleted tool finds records in CopyStorm that are no longer in Salesforce and marks them as deleted in CopyStorm.

    Refresh Formulas

    refreshFormulas

    Other Tools →Data Synchronization →Refresh Formulas

    The Refresh Formulas tool updates all formula columns in a CopyStorm database with fresh data from Salesforce. This tool is needed when a formula definition changes in Salesforce.

    Scan Timestamps

    scanTimestamps

    Other Tools →Database Validation →Scan Timestamps

    The Scan Timestamps tool does an exhaustive comparison of Salesforce versus CopyStorm record modification timestamps. Capstorm provides this tool for two reasons:

    • To provide assurance that CopyStorm is copying all records properly.

    • To assist in tracking down “after update” triggers on a table that updates the source table.

    Refresh Column(s)

    refreshColumns

    Other Tools →Data Synchronization →Refresh Columns

    The Refresh Column(s) tool updates any column in a CopyStorm database with fresh data from Salesforce. It’s primary purpose is to update a particular formula column but can be used for any column type.

    Table Editor

    tableEditor

    Other Tools →Rarely Used →Table Editor

    Manually truncates or deletes CopyStorm tables. Note that CopyStorm will recreate the tables the next time it runs.

    Count Records

    countRecords

    Other Tools →Database Validation →Count Records

    Count the number of records in a Salesforce table and the corresponding CopyStorm table and compare the results.

    Find Dirt

    Other Tools →Salesforce Data Quality →Find Dirt

    The Find Dirt tool finds data in Salesforce fields that should not be possible and does not match the field definition.

    Permission Checker

    findPermissionErrors

    Other Tools →Database Validation →Permission Checker

    The Permission Checker tool discovers tables and fields that are defined in Salesforce but not visible to the current Salesforce user.

    SQL Runner

    Other Tools →Rarely Used →SQL Runner

    Can be used to run any SQL statement against the CopyStorm database. This is not a substitute for a fully-featured tool (e.g. MySQL Workbench) but is useful when a fully-featured tool is not available.

    Fix Base64

    fixbase64

    Other Tools →Data Synchronization →Fix Base64

    Find all null base64 columns in the CopyStorm database and update with the latest value in Salesforce.

    Base64 Sanity Checker

    base64LinkChecker

    Other Tools →Salesforce Data Quality →Base64 Sanity Checker

    Discover Attachment/Content/etc. base64 columns where Salesforce returns an error when attempting to read the associated data.

    Purge Orphan base64

    purgeOrphanBase64

    Other Tools →Data Synchronization →Purge Orphan Base64

    When large Base64 field values are added to the CopyStorm database, and chunking of that data is enabled, then those field values are broken down into segments that span an auxiliary table called CopyForceTableFieldChunks. It is not possible for the database to do a CASCADING delete on the CopyStorm tables to purge those data chunks when a record is deleted so this tool is provided to purge those orphaned data chunk records.

    Image Scanner

    imageScanner

    Other Tools →Data Synchronization →Image Scanner

    This tool scans for Salesforce images not stored in the CopyStorm Database. Tool scans for columns in selected tables which contain HTML (RichText) data. When HTML contains a reference to an image the image will be read and stored in the CopyStorm database.

    Fix DocLinks

    fixDocLinks

    Other Tools →Data Synchronization →Image Scanner

    The Fix DocLinks tool repairs records in the Salesforce ContentDocumentLink table. The Salesforce ContentDocumentLink table has query restrictions that make it impossible to efficiently perform an 100% accurate incremental backup

    Base64 Export

    base64Export

    Other Tools →Data Synchronization →Export Base64 Objects to File System

    The Base64 Export tool converts document records in the CopyStorm database into files in a file system.

    Delete Salesforce Records

    deleteTool

    Other Tools → Rarely Used → Delete Salesforce Records

    Identifies, audits, and deletes a hierarchy of related Salesforce records. Supports immediate API deletion, Data Loader file generation, and Python script generation.

    -sftype

    Sandbox

    Production

    -sfuser

    Running CopyStorm/Medic in UI Mode

    Running CopyStorm/Medic in Batch Mode

    Command Line Reference

    Username

    CopyStorm Job Table

  • CopyStorm Exception

  • Permission Set

    • CopyStorm Job Logging

  • Lightning Application

    • CapStorm

  • Dashboard

    • CopyStorm

  • The Salesforce Job Logging subsystem will create records in each of the following objects when running a CopyStorm backup job. A reference is included for each object and its fields.

    API Name: CapStorm_CopyStorm_Job__c

    Field Name

    Data Type

    Description

    CopyStorm_Job_Id__c

    Number(18, 0)

    Unique ID for this job assigned by CopyStorm.

    StartTime__c

    API Name: CapStorm_CopyStorm_Job_Table__c

    Field Name

    Data Type

    Description

    CopyStormJob__c

    Master-Detail(CopyStorm Job)

    Reference to the CopyStorm Job record for this table.

    Name

    API Name: CapStorm_CopyStorm_Exception__c

    Field Name

    Data Type

    Description

    CopyStormJob__c

    Master-Detail(CopyStorm Job)

    Reference to the CopyStorm Job record for this exception.

    CopyStormJobTable__c

    The included permission set is required for the logging subsystem to function as it gives the assigned user Read, Create, Edit, Delete, View All, and Modify All permissions for the custom logging objects specified above as well as access to the CapStorm Lightning Application and CopyStorm Dashboard (along with the included starter/sample reports).

    • Permission Set Name: CopyStorm Job Logging

    • API Name: CapStorm_CopyStorm_Job_Logging

    CopyStorm Logging Tables
    installation and configuration

    Custom Objects

    CopyStorm Job

    CopyStorm Job Table

    CopyStorm Exception

    Permission Set

    Permission Set Creator

    The CapStorm Permission Set Creator tool allows you to configure a permission set that has read access (and optionally write access), create or update the Permission Set in Salesforce, and automatically assign it to the CopyStorm Salesforce user.

    The Salesforce user credentials supplied to CopyStorm must have the following permissions in order to use the Permissions Set Creator:

    • Modify All Data

    • Modify Metadata Through Metadata API Functions

    • Manage Profiles and Permissions Sets

    • System Administrator Profile

    These permissions are ONLY necessary while using the Permissions Set Creator feature.

    To access this tool, go to the “Other Tools” menu in the top-left menu bar of CopyStorm:

    A pop-up window will appear allowing you to configure and invoke the tool:

    • Provide a label and API name for the permission set.

      • If a permission set with the same API name is already present in Salesforce, the existing permission set will be updated.

    • Decide whether or not to include edit access in addition to read access for all included objects

    • Choose to automatically assign the created permission set to the CopyStorm Salesforce User.

    • Navigate to the Select Tables tab.

    • Select the objects that will be included in the permission set. Read permissions (and optionally write/edit permissions) will be granted for these objects as part of the deployment.

    • Click the Deploy button to deploy the permission set to Salesforce.

    • Navigate to the Deploy Status tab to view the deployment logs and status.

    Date/Time

    The time when the job started. Note that this time will be slightly after the start of the CopyStorm executable because it takes a few seconds for CopyStorm to initialize and connect to its data sources.

    EndTime__c

    Date/Time

    The time when the job completed.

    Transactions__c

    Number(18, 0)

    The number of Salesforce transactions – API Calls – used during the run (not including logging transactions).

    Transactions_per_min__c

    Formula (Number)

    The number of Salesforce transactions – API Calls – per minute used during the run (not including logging transactions).

    ExceptionCount__c

    Roll-Up Summary (COUNT CopyStorm Exception)

    The number of exceptions encountered during the run. If this value is non-zero then details for each exception will be recorded in the CopyStorm Job Exception object.

    CopyStormConfigFileName__c

    Text(255)

    The base name of the CopyStorm configuration file used for the run.

    CopyStormConfigFilePath__c

    Long Text Area(32768)

    The file path of the CopyStorm configuration file used for the run.

    CopyStormVersion__c

    Text(25)

    The version of CopyStorm used for the run (e.g. 10.54.3).

    CopyStormDirectory__c

    Long Text Area(32768)

    The directory in which CopyStorm was installed when the job ran.

    ElapsedTime__c

    Formula (Text)

    The time taken by the job to run.

    RecordsCopied__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records copied to the target database.

    RecordsDeleted__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records deleted from the target database.

    RecordsSkipped__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records skipped during the run.

    RecordsArchived__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records archived (Snapshot) during the run.

    FieldHistory__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of field history records created during the run.

    ImagesCopied__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of images copied during the run.

    ImagesRead__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of images read during the run.

    Text(80)

    The name of the table/object.

    StartTime__c

    Date/Time

    The time when CopyStorm began processing the table.

    EndTime__c

    Date/Time

    The time when CopyStorm finished processing the table.

    ElapsedTime__c

    Formula (Text)

    The time taken to process the table.

    RecordsCopied__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records copied to the target database table.

    RecordsDeleted__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records deleted from the target database table.

    RecordsSkipped__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records skipped for this table during the run.

    RecordsArchived__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of records archived (Snapshot) for this table during the run.

    FieldHistory__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of field history records created for this table during the run.

    ImagesCopied__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of images copied for this table during the run.

    ImagesRead__c

    Roll-Up Summary (SUM CopyStorm Job Table)

    The total number of images read for this table during the run.

    Master-Detail(CopyStorm Job)

    Reference to the CopyStorm Job table record for this exception.

    ExceptionText__c

    Long Text Area(32768)

    The message included with the exception.

    Traceback__c

    Long Text Area(32768)

    The traceback included with the exception.

  • The CopyStorm Salesforce User is the Salesforce User on the “Main” tab of CopyStorm.

  • Choose the source of the metadata that will be used to create the permission set.

    • Salesforce: CopyStorm will query the metadata API for a list of all available objects that can be included.

    • CopyStorm: CopyStorm will query the CopyStorm database (specified on the right-hand side of the Main tab of CopyStorm) metadata backup for a list of available objects that can be included (for this option, you will first need to have a backup of your Salesforce metadata created by CopyStorm).

  • Create a CapStorm Permission Set

    Delete Salesforce Records

    To access the Delete Salesforce Records tool:

    • Select “Other Tools” from the top-level menu.

    • Select “Rarely Used” and then “Delete Salesforce Records”

    Understanding the consequences of deleting a hierarchy of records and even performing a hierarchical delete are difficult problems. Examples:

    • What records will be deleted in Salesforce as a side effect if I delete the ACME account?

    • Delete the following set of old Emails AND all of their related records.

    The Delete Salesforce Records tool minimizes the effort required to understand, generate audit trails, and execute hierarchical type deletions.

    The general flow of the Delete Salesforce Records tool is fairly simple.

    • Select a Salesforce object as the root object for deletion (e.g. Account.)

    • Use a record selector to identify top level records of this root object to delete.

    • Optionally explore the records that will be deleted.

    • Delete the selected records and all children using one of the following techniques:

    The following sample screen shot illustrates that the Account Salesforce object is being selected.

    Once you have selected your Salesforce root object, you will be prompted to allow loading the relationship data for that object. This process may take a few seconds to complete. Upon completion you will be presented with a screen that shows these relationship details and the Select Records wizard tab at the top will be enabled.

    In the screen shot above the left side of the relationships panel is a tree structure that represents the hierarchy of Salesforce relationship (or dependency) objects on the Salesforce root object that was selected earlier (Account in this example.) Throughout this document we will be making reference to this Dependency Plan, and in the current implementation of the Delete Salesforce Records tool, there is only one root Salesforce object for that plan. The terms relationship and dependency are interchangeable.

    In this case the dependency plan is used to define rules for Salesforce record deletion. As one selects objects from the left-side dependency hierarchy tree, the dependency objects on that selection will appear on the right side along with some important metadata, as shown in the screen shot below.

    There are various ways in which rules can be applied surgically on each relationship object. One quick means is to right click on a relationship on the left side hierarchy tree and observe that a pop-up menu will be presented to the user, allowing for adding an exclusion rule, and possibly overriding the Cascade delete setting, as depicted in the screen shot below:

    Objects marked with the green "C" enclosed in a circle denote records that will be cascade deleted when the parent objects' records are deleted. Objects marked with the red "R" enclosed in a circle denote records that must be deleted before the parent objects' records can be deleted (restricted deletes).

    The Delete Salesforce Records tool provides these options to modify deletion behavior:

    • Max Relationship Depth: The number of relationship levels for finding deletion candidates. By default, "All" relationship levels are selected.

    • Do Not Include Non-Queryable Tables: When checked, tables that are not queryable over the API are not included. By default, this option is checked.

    • Do Not Include Non-Deleteable Tables: When checked, tables that are not deleteable over the API are not included in deletion candidate scans. By default, this option is checked.

    • Do Not Include Cascade Deletes: When checked, objects that automatically cascade delete are not included in the dependency plan. When selected, any objects marked as cascade delete (green "C") do not appear in the Relationship Dependencies graph. By default, this option is unchecked.

    Once a specific Salesforce object has been selected, the Salesforce Ids of the top level records to be deleted must be specified. This is done using a Record Selector.

    There are four ways to select top level record ids.

    The Snapshot record selector uses a previously created CopyStorm Snapshot to determine which records are candidates for deletion. When this option is selected the only deletion candidates that can occur are those that are both in the specified snapshot AND are in the selected Salesforce object table.

    The SOQL record selector expects a SOQL statement which returns top level records Ids. For example, if the selected Salesforce root object is the Account object then any of the following SOQL statements would work.

    • SELECT Id FROM Account WHERE name=’ACME’

    • SELECT AccountId FROM Opportunity WHERE ShippingCountry=’Canada’

    The Id List record selector expects a text block containing top level set of record ids. A space or comma can be used to separate record ids. This is a useful selector when only a few top level records need to be deleted.

    The File record selector expects a text file with one Salesforce Id per line.

    Once a Record Selector has been entered, click on the Scan for Records button to find all related records.

    The following example screenshot used a SOQL record selector to specify which records will be deleted.

    Though it is possible at this point to start deleting records, it is often advisable to inspect the deletion candidates first. There are two clean ways to visualize what records will be deleted.

    • Clicking on a candidate table will cause its related deletion candidate records to be display on the right side of the display.

    • Generate a HTML report which show details about each record that will be deleted. This report can be useful as as audit trail.

    Clicking on a candidate table causes a table with the following columns to be displayed.

    • Salesforce Id — the Salesforce Id of the record to be deleted.

    • Reference Field(s) — the name of fields in the record which point to other tables also in the deletion set.

    • Parent Table(s) — the name of each table the reference fields in the record are pointing to.

    In the following screen shot, the first Asset record in the list was included because:

    • Three of its reference fields point to other tables in the deletion set (AccountId, ContactId, and RootAssetId)

    • The tables the three reference fields are pointing to are Account, Contact, and Asset.

    For a complete audit trail and dependency details, the Export button is a good option.

    To export deletion candidates, click on the “Export” button.

    To export a single-file HTML Report containing all of the record Ids that are marked to be deleted, click on the Generate HTML Report button.

    The HTML report will include Record Ids and dependency information detailing why each individual record is included in the deletion plan.

    To generate Data Load files click on the Generate Data Loader button and enter a output directory when prompted. The system will generate a series of 1 column text files where:

    • The only column in each file is a Salesforce Record Id.

    • Each file will be prefixed with a four digit number which indicates the order in which it should processed by Salesforce.

    For example, the data loader files generated for the example is this document are:

    To generate a Python script which uses the CapStorm SQLForce library to delete records, click on the Generate Python button and enter an output directory when prompted. The system will generate a main python script and a directory of data files. Running the generated script will delete records from Salesforce.

    The final step is to delete records from Salesforce using one of the following techniques.

    • Generate Data Loader files which can be use to manually delete records.

    • Generate a Python script which, when run, will delete the records.

    • Delete the records immediately using API calls to Salesforce.

    Clicking on the Delete button will prompt a user for confirmation and the rapidly start delete records from Salesforce. Before beginning the deletion, the confirmation dialog requires you to enter the Salesforce Org URL for the target Salesforce.

    • The Salesforce Org URL (which appears as a somewhat randomly generated phrase) must be typed in by hand.

    • If the deletion target is a production Salesforce instance then a checkbox must be selected.

    Parameter
    Default
    Min
    Max
    Description

    The Delete Salesforce Records tool can be run in headless batch mode using the standard CopyStorm/Medic command line interface. This is useful for scheduling automated deletion jobs via Windows Task Scheduler or cron on Linux.

    To run in headless mode, first configure and test your deletion settings in the UI, then save a CopyStorm/Medic configuration file using File > Save As with the "Encrypted" and "Save Passwords" options selected. All deletion settings - including the dependency plan, record selector, and advanced options - are saved in this file.

    The tool name for the -tool switch is deleteTool.

    Windows:

    Linux:

    The -tool switch is case-insensitive - deleteTool, deletetool, and DELETETOOL are all valid.

    The following global CopyStorm/Medic switches can be used to override values stored in the configuration file at runtime:

    Switch
    Parameter
    Description

    There are no switches unique to deleteTool - all deletion configuration is controlled by the saved .copyStormMedic config file. The tool returns exit code 0 on success and 1 on failure.

    For the full global command line reference see CopyStorm/Medic.

    The Delete Salesforce Records tool supports two user-provided XML override files that control which Salesforce objects are included in a deletion and in what order they are processed. These files do not replace the tool's built-in dependency logic - they are additive, meaning entries in your override files are merged on top of the built-in defaults.

    Important: Because external files are additive only, you cannot remove a built-in exclusion via an override file. You can only add new entries.

    File Locations

    Place override files in one of the following directories. The tool checks these locations in order and loads any file it finds:

    Priority
    Path

    These paths are controlled by Java system properties set by the product's startup scripts. If none of these properties are defined in your environment, no external override files will be discovered.


    File 1: SalesforceDependencyPlanOptions.xml

    This file controls which objects are excluded from deletion, which objects should have their Salesforce cascade-delete behavior overridden, forced deletion ordering between specific objects, and per-table performance tuning.

    The filename must be exactly SalesforceDependencyPlanOptions.xml.

    Elements

    <ExcludeTable> - Excludes an object from the dependency plan entirely. Use name for an exact match or pattern for a case-insensitive Java regex match.

    xml

    <CascadeDeleteIgnored> - Tells the tool to explicitly delete children of this object rather than relying on Salesforce's cascade-delete behavior. Use this when Salesforce's cascade-delete metadata for an object is unreliable.

    xml

    <Dependency> - Forces a hard deletion ordering between two objects. The child object will always be deleted before the parent object. Both attributes are required. This is a hard constraint - if the ordering cannot be satisfied, the tool will throw an error rather than violate it.

    xml

    <DeleteTableRule> - Sets per-table performance tuning values. Use the special name __default__ to set fallback values for all tables that don't have their own rule.

    xml

    Attribute
    Description

    Full Example

    xml


    File 2: SalesforceDependencyOverride.xml

    This file handles cases where Salesforce's native relationship metadata does not correctly expose a parent-child relationship that the delete tool needs to follow. It lets you define a "parent as child" relationship so the tool discovers and deletes records it would otherwise miss.

    The filename must be exactly SalesforceDependencyOverride.xml.

    Elements

    <ParentAsChild> - Adds a synthetic child relationship to a given object. All four attributes are required - if any are missing the element is silently skipped.

    Attribute
    Description

    Example

    xml


    Gotchas

    Detail

    Generate Data Loader files which can be use to manually delete records.

  • Generate a Python script which, when run, will delete the records.

  • Delete the records immediately using API calls to Salesforce.

    • NOTE: This option does not modify tool behavior when deleting records. Objects marked as cascade delete will be automatically deleted from Salesforce when the parent object records are deleted.

  • Do Not Include Unrestricted Deletes: When checked, objects that are configured as "unrestricted delete" will not be included in the dependency plan. This means the Delete Salesforce Records tool will not explicitly delete records associated with these objects.

    • NOTE: A "Unrestricted delete" refers to an object that is both not marked as cascade delete or restricted delete for a parent relationship.

  • #
    # Record Deletion Plan Account
    # Generated Mon Sep 18 10:48:07 CDT 2023
    # Output Dir /home/greg/tmp/unittest
    #
    # The following files should be deleted from Salesforce in order.
    #
    
    0001CaseComment.txt
    0002OpportunityContactRole.txt
    0003QuoteLineItem.txt
    0004OpportunityLineItem.txt
    0005CaseFeed.txt
    0006OpportunityFeed.txt
    0007Case.txt
    0008FeedItem.txt
    0009Task.txt
    0010AccountRelationship__c.txt
    0011Quote.txt
    0012Opportunity.txt
    0013Asset.txt
    0014Contact.txt
    0015Account.txt
    #
    #
    # End of Data Loader File Plan Account
    #

    Records Per Batch

    2000

    1

    50000

    CopyStormMedic.bat -tool deleteTool -run configFile.copyStormMedic
    sh CopyStormMedic.sh -tool deleteTool -run configFile.copyStormMedic

    -sftype

    Sandbox or Production

    Override the Salesforce org type.

    -sfuser

    Username

    1

    ${copystorm.root}/config/<filename>

    2

    ${capstorm.root}/config/<filename>

    3

    <ExcludeTable name="MyAuditLog__c" />
    <ExcludeTable pattern=".*__mdt" />
    <CascadeDeleteIgnored name="CustomInvoice__c" />
    <Dependency parent="Invoice__c" child="LineItem__c" />
    <DeleteTableRule name="CustomBigTable__c" maxThreads="1" maxRequest="100" maxBatch="500" />

    name

    Salesforce object API name, or __default__ for the fallback rule. Required.

    maxThreads

    Max concurrent Salesforce API threads for this object. Optional.

    maxRequest

    <SalesforceDependencyPlanOptions>
    
        <!-- Exclude specific objects -->
        <ExcludeTable name="MyAuditLog__c" />
        <ExcludeTable name="LegacyArchive__c" />
    
        <!-- Exclude all objects matching a pattern -->
        <ExcludeTable pattern=".*__mdt" />
        <ExcludeTable pattern=".*ChangeEvent" />
    
        <!-- Explicitly delete children of this object rather than
             relying on Salesforce cascade-delete -->
        <CascadeDeleteIgnored name="CustomInvoice__c" />
    
        <!-- Force LineItem__c and Payment__c to be deleted
             before Invoice__c -->
        <Dependency parent="Invoice__c" child="LineItem__c" />
        <Dependency parent="Invoice__c" child="Payment__c" />
    
        <!-- Throttle deletion of a large object -->
        <DeleteTableRule name="CustomBigTable__c" maxThreads="1" maxRequest="100" />
    
    </SalesforceDependencyPlanOptions>

    tableName

    The object that gets the synthetic child relationship added to it.

    referenceField

    The field on tableName that holds the foreign key pointing to the parent.

    parentTable

    <SalesforceDependencyOverride>
    
        <!-- Treat ParentObject__c as a child of MyJunction__c,
             discovered via the ParentLookup__c field -->
        <ParentAsChild
            tableName="MyJunction__c"
            referenceField="ParentLookup__c"
            parentTable="ParentObject__c"
            relationshipName="ParentObjects"/>
    
    </SalesforceDependencyOverride>

    Additive only

    External files can only add entries - they cannot remove built-in exclusions or rules.

    Exact filenames required

    The filenames SalesforceDependencyPlanOptions.xml and SalesforceDependencyOverride.xml are hardcoded. Any other name will be ignored.

    <Dependency> is a hard constraint

    Dependency Plans

    Advanced Options

    Selecting Records to Delete

    Snapshot

    SOQL

    Id List

    File

    Understanding Deletion Candidates

    Exporting Records

    Generating a HTML Report

    Generating Data Loader Files

    Generating Python

    Deleting Records

    Deleting Records Immediately

    Headless CLI

    XML Dependency Plan Configuration

    The maximum number of records to process concurrently. Reducing this value lowers memory usage during very large deletions.

    Records Per Salesforce Request

    200

    1

    200

    The maximum number of records in a single API call to Salesforce. 200 is both the default and the hard ceiling imposed by the Salesforce API - this value cannot be set higher.

    Concurrent Salesforce Requests

    1

    1

    100

    The maximum number of concurrent delete requests to send to Salesforce. Increasing this speeds up large deletions. Reduce this value if record locking errors are occurring frequently - a common symptom is retries appearing in the log.

    Hard Delete

    On

    -

    -

    When enabled, records are permanently deleted and will not be placed in the Salesforce recycle bin. This is the default behavior. Requires the "Bulk API Hard Delete" permission in Salesforce. Uncheck this if you want deleted records to be recoverable from the recycle bin.

    Validate Before Deletion

    Off

    -

    -

    When enabled, the system confirms each record still exists in Salesforce before issuing a delete request. Useful when time may have passed between scanning and deleting, and the record set may have changed.

    Show Retry Reasons

    Off

    -

    -

    When enabled, if a deletion fails and the system retries, the retry reason is written to the log. The most common retry reason is record locking, which is typically resolved by reducing Concurrent Salesforce Requests.

    Show Entity Delete Errors

    Off

    -

    -

    When enabled, an error is displayed when attempting to delete a record that is already deleted. These errors are generally safe to ignore and are off by default.

    Show Invalid Cross Reference Error

    Off

    -

    -

    When enabled, an error is displayed for INVALID_CROSS_REFERENCE_KEY Salesforce errors. These are generally safe to ignore and are off by default.

    Override the Salesforce username.

    -sfpassword

    Password

    Override the Salesforce password.

    -sftoken

    Security Token

    Override the Salesforce security token.

    -dbconnection

    Connection String

    Override the database connection string.

    -dbuser

    Username

    Override the database username.

    -dbpassword

    Password

    Override the database password.

    -dbschema

    Schema Name

    Override the database schema.

    -silent

    -

    Suppress stdout progress output. Does not affect behavior or exit code.

    ${copystorm.config}/<filename>

    4

    ${capstorm.config}/<filename>

    Max records per Salesforce API request for this object. Optional.

    maxBatch

    Max records to batch together. Optional.

    The parent object that will be treated as a child in the dependency tree.

    relationshipName

    The name used to identify this relationship in the UI and dependency plan.

    If the forced ordering cannot be satisfied, the tool throws an error rather than silently reordering.

    All 4 <ParentAsChild> attributes required

    If any attribute is blank or missing the element is silently skipped with no error.