article SQL Server DataStore historical data purge script

Summary

This article provides and describes a script that is designed to purge all historical performance data from the up.time DataStore based on a cutoff date that is entered in the script. This cutoff date can be a static date or a rolling date that allows the script to be run on a recurring basis to perform regular incremental data purges.

This script is designed for a Microsoft SQL Server 2005/2008 DataStore running with an up.time 5.x monitoring station.

It is highly recommended that you review the script and are comfortable with SQL scripting before choosing to use this utility.

NOTE: THIS SCRIPT IS PROVIDED AS IS WITH NO WARRANTY OR GUARANTEE. DELETE OPERATIONS ARE FINAL. IT IS HIGHLY RECOMMENDED THAT YOU COMPLETE A DATASTORE BACKUP BEFORE USING THIS SCRIPT.


Usage

The following variables must be updated after downloading and loading the attached script into your SQL Server Management Studio:

@CUTOFF_DATE: This variable is set to today - 180 days by default. You can adjust '180' to reflect the number of days of data you wish to retain in your DB, or set the variable to a static date. All data found to be older than the @CUTOFF_DATE will be permanently deleted from the DataStore.

@DELETE_DATA: This variable is set to 0 by default, which will allow the script to execute and provide a summary of data deletion without actually deleting the data. The output should be verified and, if it is correct, set @DELETE_DATA = 1 and rerun the script to complete deletion of your historical data.

Once you have verified that the script runs correctly, you have the option of creating a SQL Server scheduled job that will re-execute the purge on a scheduled basis. For example, by using a rolling @CUTOFF_DATE of 90 days and configuring SQL Server to execute the script weekly or monthly, you will ensure that your DataStore only contains 90 days of data on a regular basis.


NOTE: The up.time Data Collector or uptime_core service must be stopped while this script is executed to ensure data consistency and integrity.

Attachments


article uptime_cleanup_mssql.sql (Size: 7.8 KB - Downloads: 1375)

Related Articles


Shrinking your MySQL DataStore

RatingViews
article

At times it may be necessary to reduce the disk space that your MySQL DataStore consumes on your monitoring station. The process of reducing your DataStore size follows the general steps that are...

By: uptime Support | Date Created: 7-31-2006 | Last Modified: 2-19-2014 | Index: 088

  11254

How to get custom script retained data values

RatingViews
article

Integer Data SELECT e.name,p.name,d.value,d.sampletime FROM erdc_int_data d, erdc_instance e, erdc_parameter p where e.erdc_instance_id = d.erdc_instance_id and p.erdc_parameter_id =...

By: uptime Support | Date Created: 10-10-2009 | Last Modified: 8-10-2011 | Index: 425

  2638

Importing Archived Data into up.time

RatingViews
article

By: uptime Support | Date Created: 6-9-2006 | Last Modified: 8-9-2011 | Index: 076

  4129

Error running Custom Script or Agent-Side Script

RatingViews
article

Symptom: script is unable to successfully pass the value for a variable name. Resolution: try using %UPTIME_VARIABLENAME% (add UPTIME_ in front of the variable name in your XML script).

By: uptime Support | Date Created: 7-12-2011 | Last Modified: 8-11-2011 | Index: 543

  2033

Migrating Your DataStore To a New Database

RatingViews
article

This article outlines how to move your DataStore between different database types.

By: uptime Support | Date Created: 2-21-2007 | Last Modified: 6-30-2011 | Index: 142

  4633

User Comments



No comments have been posted.

Copyright © 2021 IDERA, Inc.   Legal   Privacy Statement