Data Masker

About Command Line Automation

The command-line is installed alongside the Data Masker application, it takes a single parameter that points to a PARFILE containing the details of the masking job to run:

> [Installation Directory]\DataMaskerCmdLine.exe PARFILE=[path to parameter file]

For example:

> "C:\Program Files\Red Gate\Data Masker for SQL Server 7\DataMaskerCmdLine.exe" PARFILE=C:\MaskingSets\SamplePARFILE.txt
> "C:\Program Files\Red Gate\Data Masker for Oracle 6\DataMaskerCmdLine.exe" PARFILE="C:\Masking Sets\Sample PARFILE.txt"

The Parameter File

The parameter file can specify the following options:

ParameterRequired?Description
MASKINGSETRequiredThe full path of the masking set to be run.
LOGFILEDIRRequiredThe full path to the directory where log files will be placed.
DATASETSDIRRequired

The full path to the directory containing the datasets. Unless you have created your own directory, the datasets are installed alongside Data Masker in the following locations:

  • SQL Server: 
    • C:\Program Files\Red Gate\Data Masker for SQL Server 7\DataSets 
  • Oracle: 
    • C:\Program Files\Red Gate\Data Masker for SQL Oracle 6\DataSets 
REPORTSDIRRequiredThe full path to the directory where the reports should be exported.
INTERIM_REPORTSOptional

Either true or false. If not specified, the default value will be false.

If true, the reports in the REPORTSDIR will be overwritten about once every minute, should you wish to track progress while the command-line is running.

LOGINSUBOptional

Add a LOGINSUB line to the file for each controller in the masking set that needs to be changed to point to a different database (or with a different user account).  

For more information about login substitution see: 

DMSSUBVALUExxOptional

SQL Server Only. Data Masker will replace any instance of these parameter names with their value in any SQL. The xx is a two-digit numeric value. See substitution values for more details.

DMOSUBVALUExxOptional

Oracle Only. Data Masker will replace any instance of these parameter names with their value in any user-specified SQL. The xx is a two-digit numeric value. See substitution values for more details.

  

DMSSUBVALUExx (SQL Server version) / DMOSUBVALUExx (Oracle version)

Up to twenty replacement strings can be specified in the parameter file. These runtime substitution values are designed to permit generic SQL statements to be dynamically adjusted at runtime for specific targets during batch operations.

Note: The keywords for these replacement strings are DMSSUBVALUE00 to DMSSUBVALUE19. If the text %DMSSUBVALUExx% is used in a Command rule or in the Where Clause of a masking rule, the value associated with that keyword will be replaced at runtime before the rule is executed.

For example, if a Command rule included a statement like:

TRUNCATE TABLE %DMSSUBVALUE05%_TEMP;

and the parameter file contained a line stating DMSSUBVALUE05=TESTUSER then the actual statement that would be executed would be:

TRUNCATE TABLE TESTUSER_TEMP;

The value TESTUSER would be substituted for the %DMSSUBVALUE05% text in the SQL statement immediately before the statement was executed.

Examples

SQL Server PARFILE

MASKINGSET=C:\Program Files\Red Gate\Data Masker for SQL Server 7\Demo.DMSMaskSet 
LOGFILEDIR=C:\TEMP\Data Masker\
DATASETSDIR=C:\Program Files\Red Gate\Data Masker for SQL Server 7\DataSets 
REPORTSDIR=C:\TEMP\Data Masker\
INTERIM_REPORTS=false 
LOGINSUB=placeholder-login@DEV-DB[DataWarehouse]||DataMasker/SecurePassword@STAGING\SQL2019[DataWarehouseMasked]
-- Substitution values
DMSSUBVALUE00=DM_INVOICE_LINE_HISTORY
DMSSUBVALUE05=DM_INVOICE_LINE_HISTORY

Oracle PARFILE

MASKINGSET=C:\Program Files\Red Gate\Data Masker for SQL Oracle 6\Demo.DMSMaskSet 
LOGFILEDIR=C:\TEMP\Data Masker\
DATASETSDIR=C:\Program Files\Red Gate\Data Masker for SQL Oracle 6\DataSets 
REPORTSDIR=C:\TEMP\Data Masker\
INTERIM_REPORTS=false 
--LOGINSUB=DummyLogin@DummyServer[DummyDatabase]||DataMasker/DataMasker@DEMODB[DMTest] 
--LOGINSUB=XXXLogin@XXXServer[XXXDatabase]||DBSSourceUser/DBSSourceUser@N2KBUILD-PC\N2KTEST1[DBSSource]

DMOSUBVALUE00=DM_INVOICE_LINE_HISTORY
DMOSUBVALUE05=DM_INVOICE_LINE_HISTORY

Exit Codes

The command-line will return an exit code to indicate success or failure; if the run of the masking rules was successful, then this exit code will always be zero. Any non-zero exit code implies that an error occurred while opening the masking set or while running the masking rules. If a non-zero exit code is returned, the log file should always be examined to determine the error that occurred. The defined exit codes are:

Exit CodeDescription
0The command-line has successfully run the masking set.
99An unhandled exception occurred.
100The masking run failed but no specific error was reported.
101There was an unexpected error trying to start the logging system.
102There was an error trying to create the log files, check that the LOGFILEDIR directory exists and the user running the command-line has sufficient privileges to access that directory.
103There was an error in parsing the command-line arguments or the PARFILE contents.
104The LOGFILEDIR directory could not be found or there were permissions issues.
105The DATASETDIR directory could not be found or there were permissions issues.
106There was an processing the datasets found in the DATASETDIR.
107The REPORTSDIR directory could not be found or there were permissions issues.
108The masking set specified in the MASKINGSET parameter could not be found.
109There was an error opening the masking set.
110There was an error processing the LOGINSUB substitution keyword in the parameter file.
200There was an error executing one or more masking rules.


If an error occurs there will be more detail in the log that is created in the LOGFILEDIR directory, some information will be written to the console output. 

If running from the standard command-line then  `echo %errorlevel%` can output the exit code. For example:

C:\Program Files\Red Gate\Data Masker for SQL Server 7>DataMaskerCmdLine.exe PARFILE=C:\workspace\data-masking\DMV6\DMS_TestSets\DebugPARFILE.txt
...
C:\Program Files\Red Gate\Data Masker for SQL Server 7>echo %ERRORLEVEL%
200




Didn't find what you were looking for?