Working with the Clean-up Utility
The Clean-up Utility DB-Cleanup.exe
is a command line utility that can be used to delete workflow Executions and History Records in the database.
Important! Stop the Release Manager before running the DB-Cleanup tool to avoid conflicts in the database.
This page includes the following:
After running CDA for a while, the CDA database may contain an increasing number of outdated records, especially from workflow executions. To keep the size of the Continuous Delivery Automation database small and ensure a good performance, you may want to remove outdated records. To do so, you can run the Clean-up Utility.
Important! The Clean-up Utility requires a direct database connection and operates through SQL statements. Therefore, the computer hosting the utility must allow a connection to the CDA database server.
The user specified in the connection string must have CRUD privileges on all tables of the CDA database and the right to create temporary tables in the database.
Installing the Clean-up Utility
If the Clean-up utility DB-Cleanup.exe
is not already available on your system, perform the following steps.
To Install the Clean-Up Utility
Tip: Save the Clean-Up Utility in the following folder: C:\Automic\Release.Manager\Utilities
- Copy the
DB-Cleanup.exe
file to a machine which has access to the CDA database server. - Configure the clean-up utility according to your needs.
Configuring the DB-Cleanup.exe.config File
Note: The DB-Cleanup.exe.config file must be stored in the same folder as the DB-Cleanup.exe.
The parameters are organized in the following sections:
- startParameters
-
connectionStrings from
customer.config
(path: Automic\Release.Manager\WebUI\customer.config)Connection string syntax:
"Data Source=##DB SERVER##;Initial Catalog=##DB NAME##;User ID=##DB USER##;Password=##DB PASSWORD##,"database Schema=##DB SCHEMA##
Parameters
- Data Source: Replace ##DB SERVER## with your database server name, to which you have connected.
- Initial Catalog: Replace ##DB NAME## with your database name (for example, CDA).
- User ID: Replace ##DB USER## with your database user:
- Password: Replace ##DB PASSWORD## with your database user password.
Important! Unencrypted passwords cannot start with --10.
Examples
-
SQL Server Database:
connectionString=
"Data Source=##DB SERVER##;Initial Catalog=##DB NAME##;User ID=##DB USER##;Password=##DB PASSWORD##"
<add connectionString="Data Source=tcp:localhost,1433;Initial Catalog=ARA;User ID=AUTOMIC;Password=P@ssw0rd" name="Database"/>
-
Oracle Database:
connectionString=
user id=##DB USER##;password=##PASSWORD##;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST= ##DB SERVER##)(PORT=##PORT OF LISTENER##))(CONNECT_DATA=(SERVICE_NAME=##DB NAME##)))
<add connectionString="User Id=ARA_DEV_8_0;password=ara;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.40.58)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=vviedb02.sbb01.spoc.global)))" name="Database"/>
-
PostgreSQL Database:
connectionString=
"User ID=<db_user>;password=<db_password>;Host=<db_host>;Port=<db_port>;Database=<db_name>;searchpath=<db_schema>"
Both sections can be encrypted.
Tip: You can set fixed parameters (for example, Application names) with <add key> tags. For example: <add key "applications" value="MyApp1,MyApp2">
You can pass every parameter either via XML configuration file Db-Cleanup.exe.config
or directly together with the command line call (Both, dash- and colon-syntax are supported to pass parameters).
Rules for combining parameters:
- If parameters are passed via the command line call, they overwrite the corresponding values in the
Db-Cleanup.exe.config
- If applications are set but no workflows: all executions/packages of the specified applications are deleted.
- If applications and workflows are set but the combination of specified applications and workflows does not exist: no executions are deleted.
Case-sensitivity of parameters depends on the underlying database:
- For MS SQL Server, parameters are case-insensitive
- For Oracle Database and PostgreSQL Server, parameters are case-sensitive
Available Commands
You can run the following commands:
- execution
- package
- historyrecord
- artifact
Important! If no command is specified, executions are cleaned up.
Examples
\DB-Cleanup.exe historyrecord
-
No command is specified (executions will be cleaned up):
\DB-Cleanup.exe --olderThan 120 --archivedOnly true --applications "CRM System"
-
HistoryRecord command is specified:
\DB-Cleanup.exe historyrecord --olderThan 120 --keepAtLeast 20
Input Parameters
The table below lists the inputs input parameters available for all commands:
Available for | Parameter | Mandatory | Type | Default | Description / Help message in CLI |
---|---|---|---|---|---|
All commands | connectionString | Yes | String | - |
Connection string to connect to the CDA database. |
All commands | verbose | No | string | min |
Level of textual output to the screen or to a log file. Possible values:
|
All commands | fi | No | string | - |
(Optional) mirrors screen output including timestamps to a log file. |
All commands | No | - | - |
Displays the parameters and their description for the DB Clean-up tool. |
|
All commands | olderThan | No | Number | 90 |
Only entities having an end-date older than the specified number of days before the current date are deleted. Important! Only whole days are selected. Example:
Note: olderThan=0 means that all entities are deleted. Default: 90 |
All commands | keepAtLeast | No | Number |
Defines how many entities must remain per parent entity. Example: keepAtLeast=20 means that at least the 20 latest history records of each parent entity remain in the system and are not deleted - even if they match the olderThan or some other criteria. \DB-Cleanup.exe historyrecord --olderThan 120 --keepAtLeast 20 Default values:
|
Command-specific Parameters
Executions
Command name: execution
Parameter | Mandatory | Type | Default | Description / Help message in CLI |
---|---|---|---|---|
applications | No | String | - |
Comma-separated list of application names. If set, only executions of the specified applications are considered to be deleted. Example: CRM System, Billing System |
workflows | No | String | - |
Comma-separated list of workflow names. Note: For application workflows, this parameters has to be set together with the applications parameter. If the applications parameter is not set, only general workflows are considered to be deleted. Example: Install, Uninstall. |
archivedOnly | No | Boolean | false |
Flag forcing whether all executions or only archived ones should be considered to be deleted. Values:
|
force | No | Boolean | false |
Flag forcing whether the utility should also consider to delete executions that belong to a current installation or not. Values:
|
id | No | string | - |
Comma-separated id of executions to be deleted. The number of Ids to be specified is limited to 100. This switch cannot be used together with any of the other filtering switches (olderThan, keepAtLeast, applications, workflows, archivedOnly). |
If an invalid value for a parameter is defined, the tool prints an error message and quits.
Conditions for Deleting Executions
The Clean-up Utility only deletes a record if all of the following conditions are fulfilled:
- The workflow execution must be in its final state - see Viewing Workflow Executions and Queue Runs
- By default, the workflow execution must not belong to a current installation (force flag is set to false, see Parameters)
- Only if the force flag is explicitly set to true, also workflow executions for current installations are considered to be deleted (force flag is set to true, see Parameters)
- All conditions that are stated via Parameters are fulfilled
Packages
Command name: package
Parameter | Mandatory | Type | Default | Description / Help message in CLI |
---|---|---|---|---|
applications | No | String | - |
Comma-separated list of application names. If set, only executions of the specified applications are considered to be deleted. Example: CRM System, Billing System |
archivedOnly | No | Boolean | false |
Flag forcing whether all packages or only archived packages should be considered to be deleted. Values:
|
force | No | Boolean | false |
Flag forcing whether the utility should also consider to delete packages that belong to old installations. Values:
|
id | No | string | - |
Comma-separated id of packages to be deleted. The number of Ids to be specified is limited to 100. This switch cannot be used in conjunction with any of the other filtering switches (olderThan, keepAtLeast, applications, workflows, archivedOnly). |
If an invalid value for a parameter is defined, the tool prints an error message and quits.
Conditions for Deleting Packages
The Clean-up Utility only deletes a record if all of the following conditions are fulfilled:
-
Packages belonging to an execution, a patch chain, a package workflow instance (package hook) or a current installation are not deleted regardless of the --force flag and other criteria.
Artifacts
Command name: artifact
Parameter | Mandatory | Type | Default | Description / Help message in CLI |
---|---|---|---|---|
sources | No | String | - |
Comma-separated list of Artifact Source names. If set, only Artifacts of the specified Artifact Sources are considered to be deleted. Example: "Internal Nexus,Department SMB". |
archivedOnly | No | Boolean | false |
Flag forcing whether all artifacts or only archived artifacts should be considered to be deleted. Values:
|
force | No | Boolean | false |
Flag forcing whether the utility should also consider to delete artifacts that belong to old installations. Values:
|
id | No | string | - |
Comma-separated id of artifacts to be deleted. The number of Ids to be specified is limited to 100. This switch cannot be used in conjunction with any of the other filtering switches (olderThan, keepAtLeast, applications, workflows, archivedOnly). |
If an invalid value for a parameter is defined, the tool prints an error message and quits.
Conditions for Deleting Artifacts
The Clean-up Utility only deletes a record if all of the following conditions are fulfilled:
- Artifacts belonging to current installations cannot be deleted.
History Records
Command name: historyrecord
See: Common Parameters
Return Codes
After each run, the Clean-up utility returns an exit code to indicate the outcome of action. You may use this code in a script.
The utility returns the following codes:
Value | Meaning |
---|---|
0 | Success |
1 | Unable to connect to the database |
99 |
Unexpected error Note: To resolve this, check the log files. |
Configuration Files
Common parameters can be specified in the configuration file with the same name as in the command line parameter.
<appSettings> <add key="verbose" value="max" /> <add key="force" value="false" /> </appSettings>
Command-specific parameters have the following format: [commandname].<parameter_name>
Example:
<appSettings> <add key="verbose" value="max" /> <add key="force" value="false" /> <add key="package.keepAtLeast" value="100" /> <add key="package.olderThan" value="90" /> </appSettings>
Command-specific parameters without prefix are considered as execution parameters:
<appSettings> <add key="verbose" value="max" /> <add key="force" value="false" /> <add key="keepAtLeast" value="100" /> <!-- this is considered as an execution command parameter --> </appSettings>
Examples for CLI calls and configuration file
Dash-syntax:
\DB-Cleanup.exe --olderThan 120 --archivedOnly true --applications "CRM System"
Colon-syntax:
\DB-Cleanup.exe olderThan:120 archivedOnly:true applications: "CRM System"
DB-Cleanup.exe.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings> <add name="Database" connectionString="Data Source=##DB SERVER##;Initial Catalog=##DB NAME##;User ID=##DB USER##;Password=##DB PASSWORD##"/> </connectionStrings>
<appSettings> <add key="verbose" value="max"/> <add key="force" value="false"/> </appSettings>
</configuration>
See also: