All pages
1 of 24

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

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

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.

Running CopyStorm/Medic in UI Mode

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.

Running CopyStorm/Medic in Batch Mode

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

Command Line Reference

Switch
Parameter
Description

-sftype

Sandbox

Production

-sfuser

Username

Override the Salesforce username in the configuration file.

-sfpassword

Password

Override the Salesforce password in the configuration file.

-sftoken

Security Token

Override the Salesforce security token in the configuration file.

-dbconnection

Connection String

Override the database connection string in the configuration file.

-dbuser

Username

Override the database username in the configuration file.

-dbpassword

Password

Override the database password in the configuration file.

-dbschema

Schema Name

Override (or set) the database schema value in the configuration file.

-proxyHost

Host Name

Override the proxy server in the configuration file. Example: proxy.capstorm.com

-proxyPort

Port Number

Override the port number used by the proxy server.

-proxyUser

Username

Override the username used to authenticate with the proxy server.

-proxyPassword

Password

-apiTraceFile

filename

Write the entire conversation with the Salesforce API to a file (the file may be huge).

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.

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.

Running Fix DocLinks as a Batch Job

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

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

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

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

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!).

Running Base64 Export in a GUI

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:

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.

Base64 Export Parameters

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.

File Rules

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.

File Name and Duplicate (Clobbering) Rules

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.

Record Selector Rules

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.

Point-In-Time Export From Snapshot

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.

Adding a Field to the Base64 Exporter

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.

Running Base64 Export as a Batch Job

The Base64 Export tool cannot be executed as a batch job.

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”.

Step 1: Set Search Parameters

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 Size

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.

Step 2: Check Hyperlinks

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.

Summary

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.

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"

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”

Running the Partition Editor GUI

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.

  3. Column Name

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

  4. Type

    1. The Salesforce field type.

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.

  • A local folder on the CopyStorm server.

  • An AWS S3 Bucket.

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.

    1. If “New Partition” was selected, a CREATE TABLE statement will be executed to create the new partition.

    2. If a pre-existing partition was selected, an ALTER TABLE statement will be executed to add the selected fields to the target partition.

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

  4. Update CopyStorm metadata for the selected fields.

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

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.

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.

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.

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.

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

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

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

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, refer to this article.

Using the Tool

  • 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:

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).

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

  • 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.

Running Count Records as a Batch Job

  • Windows

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

  • Linux / Mac OS

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

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

Notification emails will be sent to this white space separated list of email addresses.

Subject

Parameter Name
Required
Description

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.

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

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.

SMTP Notifications

Subject

“{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”.

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.

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 .

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

here
here

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.

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:

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

Run Scan Timestamps in a GUI

Running Scan Timestamps as a Batch Job

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.

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

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.

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

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

Managing Stale Formulas Automatically

Running Refresh Columns as a Batch Job

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.

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.

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

Running Table Editor in a GUI

Running Table Editor as a Batch Job

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.

Path Format

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

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

Segment
Characters
Example (ID: 001ZZ010000000000AA)

Level 1

0–4 (5 chars)

001ZZ

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?

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

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

Bucket name

Yes (configurable)

Folder prefix

Yes (configurable, may be empty)

AWS region

Configured separately, not part of the path

Salesforce record ID

Yes. Determines all subfolders and filename

Salesforce object/table name

No

Files Per Record

What Is and Isn't in the S3 Path

Org ID

No

Backup date or job ID

No

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

    The maximum number of records to process concurrently. Reducing this value lowers memory usage during very large deletions.

    Records Per Salesforce Request

    200

    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

    Override the Salesforce username.

    -sfpassword

    Password

    Override the Salesforce password.

    1

    ${copystorm.root}/config/<filename>

    2

    ${capstorm.root}/config/<filename>

    3

    ${copystorm.config}/<filename>

    4

    ${capstorm.config}/<filename>

    <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

    Max records per Salesforce API request for this object. Optional.

    maxBatch

    Max records to batch together. Optional.

    <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

    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.

    <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

    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.

    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

    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.

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