Aireforge OmniCompare 0.9.0 was the first release to ship with the CLI module. This is a separate application, allowing comparisons to be called from 3rd party applications, such as SQL Server Agent jobs, custom scripts and software deployment tools including Octopus Deploy. OmniCompare CLI will then feedback basic information using termination or error codes; much like log shipping alerts.
The information required to perform the comparison and the credentials required to access the servers are stored within the .adc export file, therefore the main OmniCompare application will be required to perform any future changes such as new servers or new / updated comparisons.
What is OmniCompare?
Comparing trace flags via the command-line
Creating the comparison file
Open OmniCompare and select the servers you wish to compare. Once selected, you can now choose a full comparison or restrict it to individual checks.
For the purposes of this blog, we’ll limit the comparison to trace flags.
Note: Although trace flag comparisons work for both SQL Server and AzureDB, many of them are not interchangeable as AzureDB is a very different database to SQL Server. AzureDB also has many trace flags enabled by default (17 at the time of writing).
Checking current values
If no differences are found, nothing will be displayed. Although it’s often interesting to check the current values. This can be done by changing the results filter from Differences only to All.
Showing all results has highlighted that each instance has the non-standard trace flag 1222 enabled, which enabled by Redgate SQL Monitor to improve deadlock information.
Exporting the comparison file
OmniCompare CLI is a lightweight application, therefore the comparison file must be created using the main OmniCompare application and exported. This exported file contains the servers to check, authentication credentials and the comparisons to perform.
To create the .adc file, select the command line icon at the top right of the comparisons section. You will then be prompted to enter a secure password and the location of the saved file.
We will save this file to d:\tf.adc.
Download OmniCompare (inc. CLI)
Using OmniCompare CLI
The OmniCompare CLI executable resides in the OmniCompare program folder. The argument for the application will be logged out if none are passed in or the help argument (-h) is use.
Performing a CLI comparison
To perform a trace flag comparison against the servers detailed above we simply pass in the comparison file and password.
For the purposes of this blog I have enabled full logging, although this should be used for debugging only as a lot of information is logged; especially during full comparisons of large estates.
omnicomparecli.exe -i d:\tf.adc -p <password> -v full
This command could then be run from a SQL Server Agent job or from software deployment tools or from your own custom scripts.
We will now enable trace flag 1117 on the SQL2014 instance to demonstrate how the application changes. OmniCompare CLI has highlighted the change and returned an error code of 1. This error code could be caught and an alert raised or a deployment aborted.
The information detailed above could be logged to file using the -o command, although a simpler option would be to run the comparison via the OmniCompare application.
Discrepancies between configuration settings or database objects can be difficult to identify, especially with larger estates or multiple developer environments. Custom scripts or policy-based management could be used to check some of these settings but they will require updating and only work if the script or rule has been created.
OmniCompare checks a large and growing number of settings, highlighting unexpected changes and preventing configuration drift between instances that should be the same.
Other useful pre-deployment checks
- Counts of database objects (tables, columns, indexes, functions, views etc.).
- Server triggers,
- CLR assemblies,
- Trace flags,
- Operators, users or permissions have been applied,
and database settings such as delayed durability, RCSI etc.
Download OmniCompare (inc. CLI)