# MGMT Server Database Maintenance

**URL:** <https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018>\
**Category:** Right Click Tools- Enterprise\
**Created:** [May 6, 2021, 12:55pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018 "2021-05-06T12:55:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![smolikj](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@smolikj](https://discourse.recastsoftware.com/u/smolikj)\
**Post date:** [May 6, 2021, 12:55pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/1 "2021-05-06T12:55:31Z")

</div>

Hello. Is there some manual, how to properly make management server database maintenance? Is there some settings for automatic DB maintenance? Im asking, because our database became too big. Thank You very much.

---

<div class="post-metadata">

**Author:** ![CourtneyB](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CourtneyB](https://discourse.recastsoftware.com/u/CourtneyB)\
**Post date:** [May 6, 2021, 9:09pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/2 "2021-05-06T21:09:05Z")

</div>

If you go to settings on the Recast Management Sever portal, you can change the MaxAuditLogAge and MaxSnapshotAge so it will delete records older than the time set.

---

<div class="post-metadata">

**Author:** ![rtbywalski](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/r/b487fb/32.png) [@rtbywalski](https://discourse.recastsoftware.com/u/rtbywalski)\
**Post date:** [January 20, 2022, 6:58pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/3 "2022-01-20T18:58:45Z")

</div>

So if it is set to 00:00:00 does that mean there is no maintenance set?

---

<div class="post-metadata">

**Author:** ![TroyWatson](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/t/3be4f8/32.png) [@TroyWatson](https://discourse.recastsoftware.com/u/TroyWatson)\
**Post date:** [April 29, 2022, 7:37pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/4 "2022-04-29T19:37:55Z")

</div>

I apparently missed that setting as well. Any idea on when the management server will go in and clean up the older records?

---

<div class="post-metadata">

**Author:** ![CourtneyB](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/c/cc9497/32.png) [@CourtneyB](https://discourse.recastsoftware.com/u/CourtneyB)\
**Post date:** [April 29, 2022, 8:17pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/5 "2022-04-29T20:17:53Z")

</div>

If it’s set to all 0’s there is no maintenance set and will keep all records. If you change that setting, it will delete the records at midnight at the set interval.

---

<div class="post-metadata">

**Author:** ![TroyWatson](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/t/3be4f8/32.png) [@TroyWatson](https://discourse.recastsoftware.com/u/TroyWatson)\
**Post date:** [April 29, 2022, 10:27pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/6 "2022-04-29T22:27:19Z")

</div>

Spiff. Thank you, Courtney

---

<div class="post-metadata">

**Author:** ![StandaE](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/s/6a8cbe/32.png) [@StandaE](https://discourse.recastsoftware.com/u/StandaE)\
**Post date:** [August 5, 2022, 8:52am UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/7 "2022-08-05T08:52:40Z")

</div>

Hello. But we stil have problem. Run of the scheduled task ends with an error. Returned code 214794201. Fuj. In Application Event log error Source = .NET Runtime, Event ID 1000, … Failed executing DbCommand (30,926ms) [Parameters=[@p0=’?’ (DbType = Int64)], CommandType=‘Text’, CommandTimeout=‘30’] …  
Runs from Powershell … “Invoke-RestMethod https://our\_server.contoso.com:444/api/TaskScheduler/RunAuditLogCleanupTask -Method Post -UseDefaultCredentials” many times with error: “Invoke-RestMethod: Response status code does not indicate success: 500 (Internal Server Error)”. (error Event recorde same). Then “maybe” one time success. DB size 80 GB. And more. Any idea? Please.Thanks

---

<div class="post-metadata">

**Author:** ![BrandenH](https://discourse.recastsoftware.com/user_avatar/discourse.recastsoftware.com/brandenh/32/378_2.png) [@BrandenH](https://discourse.recastsoftware.com/u/BrandenH)\
**Post date:** [August 5, 2022, 2:14pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/8 "2022-08-05T14:14:39Z")

</div>

Hello,

Another option that might be helpful is switching the recovery model for your ‘RecastManagementServer’ database to simple recovery. This reduces space being taken up by log files.

More info: [Recovery Models (SQL Server) - SQL Server | Microsoft Docs](https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/recovery-models-sql-server?view=sql-server-ver16)

If the storage for the DB is nearly full, I would recommend adding additional storage before making the change. You can reduce allocated storage after switching to simple.

Please consult your SQL admin before proceeding.

Best,

Branden

---

<div class="post-metadata">

**Author:** ![smolikj](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@smolikj](https://discourse.recastsoftware.com/u/smolikj)\
**Post date:** [August 9, 2022, 10:39am UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/9 "2022-08-09T10:39:14Z")

</div>

Hello Branden. First, thank You for Your answer. Me and StandaE, We are both from the same company, so I will react this time. We have 114,37 GB Free Space on DB. DB was set to simple. Access Rights are DB\_owner, so everything looks properly set and we are still facing this issue. Maybe DB command timeout should be increased, because 30 seconds are simply not enough to finnish cleanup request. Is there some way, how we can increase this setting? We tried to look for it and didn’t found it. Do You know, how, please? Many thanks to You.

---

<div class="post-metadata">

**Author:** ![BrandenH](https://discourse.recastsoftware.com/user_avatar/discourse.recastsoftware.com/brandenh/32/378_2.png) [@BrandenH](https://discourse.recastsoftware.com/u/BrandenH)\
**Post date:** [August 9, 2022, 8:54pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/10 "2022-08-09T20:54:50Z")

</div>

I’ll see what I can find out for you. If you’d like, you could try running this command against the RecastManagmentServer database which will attempt to delete audit log entries older than 7 days.

```auto
DECLARE @Rows INT
Declare @Now date Set @Now = Getdate()-7
SET @Rows = 1WHILE (@Rows > 0)
BEGIN
    DELETE TOP (5000) from ActionExecutionResults
	where Id in (Select AER.Id from ActionExecutionResults AER
				join [dbo].[ActionExecutions] AE on AER.ActionExecutionID = AE.ID
				Where AE.Created < @Now) SET @Rows = @@ROWCOUNT
END

```

Once the audit log storage is a bit smaller the scheduled task may be successful with its current settings.

---

<div class="post-metadata">

**Author:** ![BrandenH](https://discourse.recastsoftware.com/user_avatar/discourse.recastsoftware.com/brandenh/32/378_2.png) [@BrandenH](https://discourse.recastsoftware.com/u/BrandenH)\
**Post date:** [August 9, 2022, 8:55pm UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/11 "2022-08-09T20:55:38Z")

</div>

Just a heads up, it could take hours to complete depending on how many rows it has to go through.

---

<div class="post-metadata">

**Author:** ![smolikj](https://discourse.recastsoftware.com/letter_avatar_proxy/v4/letter/s/ce73a5/32.png) [@smolikj](https://discourse.recastsoftware.com/u/smolikj)\
**Post date:** [August 10, 2022, 9:15am UTC](https://discourse.recastsoftware.com/t/mgmt-server-database-maintenance/1018/12 "2022-08-10T09:15:32Z")

</div>

HI. Many thanks. We will try it…
