Lesson 8b Recap Slides
Lesson 8b Recap Slides
Before deleting the data in Logs and QueueItems, copy it to the corresponding Archive tables.
Deleting Old Data - Queue Items
To delete old successfully processed queue items, for example those that are older than 45 days,
use the following query, which can be run manually or scheduled as a SQL Server Job. A different
number of days can be set by simply replacing the number 45 in the last line with the desired
number.
Optionally, include the TenantId.
Usage
Elastic-Delete-Data.ps1 [-daysToKeep] <int> [-elasticURL] <string> [[-tenantName] <string>]
[[-elasticUser] <string>] [[-elasticPassword] <string>]
The daysToKeep and elasticURL parameters are mandatory.
If no specific tenant name is provided, “default” is assumed.
If X-Pack is installed and enabled, the script needs to authenticate to Elasticsearch. Provide the
username and the password using the corresponding arguments.
Examples:
.\Elastic-Delete-Data.ps1 -daysToKeep 91 -elasticURL http://elasticserver:9200
.\Elastic-Delete-Data.ps1 -daysToKeep 60 -elasticURL http://elasticserver:9200
-tenantName rpacoe
.\Elastic-Delete-Data.ps1 -daysToKeep 91 -elasticURL http://elasticserver:9200
-elasticUser superuser -elasticPassword secret01
Backup database
Implement regular backups of the SQL Server database.
Perform full backups weekly, and incremental backups daily.
The recommendation is to use the DatabaseBackup stored procedure that is created using the
award-winning script at this location.