Retrieving the script text for a deleted script task using a database backup
search cancel

Retrieving the script text for a deleted script task using a database backup

book

Article ID: 171167

calendar_today

Updated On:

Products

IT Management Suite

Issue/Introduction

How to retrieve the script text for a deleted script task using a database backup?


You have accidentally deleted tasks containing useful scripts and wish to retrieve them from an available database backup.

Environment

Symantec Management Platform 8.1 RU5

Resolution

Follow the steps below to get the raw item statexml and script text,

1. Restore the Symantec_CMDB database backup as a new (temporary) database.
2. Run the following SQL Query in SQL Management Studio to get a list of recently deleted items.

--List of recently deleted items.
Select * From ItemDeleted
Order By DeletedDate DESC

3. Once the item GUID is known, use the following SQL Query to get the StateXML.
Click on the links in the StateXML column to see the Item State as XML.
Look for the </scriptText> tag.

--Get ItemVersionData as XML for a specific item(task).
Select
ivd.Name [Item Name]
, iv.ItemGuid [ItemGuid]
, iv.Version [ItemVersion]
, CAST(ivd.State as xml) as [StateXML]
From ItemVersions as iv
JOIN ItemVersionData as ivd
ON iv.VersionGuid=ivd.VersionGuid
WHERE iv.ItemGuid='<GUIDVALUE>'  /*Guid of the deleted script task.*/
Order By iv.Version DESC