# How do you keep the data in your Mautic DB trimmed and gdpr compliant?

**URL:** <https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565>\
**Category:** General Discussion\
**Created:** [March 23, 2020, 2:46pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565 "2020-03-23T14:46:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 23, 2020, 2:46pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/1 "2020-03-23T14:46:54Z")

</div>

Hi all

I was wondering how you go about keeping your Mautic DB trimmed and void of old outdated leads. For example, we’re having trouble with our Mautic instance growing at a rapid pace and being slow and difficult to use. One way of managing this would be to delete leads and their data. Is anyone else doing this?

Best regards

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [March 23, 2020, 3:05pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/2 "2020-03-23T15:05:21Z")

</div>

Hi there,

Take a look at the documentation: [https://docs.mautic.org/en/setup/cron-jobs#cleanup-old-data](https://docs.mautic.org/en/setup/cron-jobs#cleanup-old-data)

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 23, 2020, 3:32pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/3 "2020-03-23T15:32:22Z")

</div>

Hi @silavapi

Is it the gdpr compliance you’re referring to? If not, and you’re instead referring to how one keeps the Mautic DB trimmed I don’t think the cron job will help us much. The docs state that `Currently supported are audit log entries, visitors (anonymous contacts), and visitor page hits. ` and we don’t use that functionality of Mautic to any larger extent. We just add our contacts and segment them and send emails through different campaigns. So I don’t think the Cleanup Old Data cron job will do much good for us. What I’m looking for is a way to delete all contacts which haven’t been active (this could be determined by when the last opened an email we sent) in a certain time period. And when a contact has been deleted all the data connected with that contact should also be deleted, which in turn saves significant space

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [March 23, 2020, 6:00pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/4 "2020-03-23T18:00:15Z")

</div>

> [@silavapi](#):
>
> [Cron jobs | Mautic](https://docs.mautic.org/en/setup/cron-jobs#cleanup-old-data)

Indeed, the gdpr flag enables you to clean up old leads who are no longer active. Perhaps @npracht could ask the team to give some more insights, as I believe Webmecanik contributed most of the stuff around the GDPR cleanup commands.

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 23, 2020, 9:42pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/5 "2020-03-23T21:42:22Z")

</div>

I would like to delete leads which have been inactive for more than 1 year. Is it possible to decrease the time period from 3 to 1 year for the gdpr command? If so, I think this cron job would be very useful.

Also, do you know what makes a lead count as inactive? Is it only that it hasn’t opened any emails? Or is it also that we haven’t sent any emails to the lead?

---

<div class="post-metadata">

**Author:** ![npracht](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/npracht/32/240_2.png) [@npracht](https://forum.mautic.org/u/npracht)\
**Post date:** [March 25, 2020, 2:14pm UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/6 "2020-03-25T14:14:28Z")

</div>

Hi @lalurran !  
You can change the date of 3 years in the code, this is not settable. This is just here: [https://github.com/mautic/mautic/blob/8ae5196f5ec843b4167c7dffd5da61baab24a65a/app/bundles/CoreBundle/Command/CleanupMaintenanceCommand.php#L85](https://github.com/mautic/mautic/blob/8ae5196f5ec843b4167c7dffd5da61baab24a65a/app/bundles/CoreBundle/Command/CleanupMaintenanceCommand.php#L85)

- If you use `mautic:maintenance:cleanup` then all anonymous inactive leads are deleted after 3 years.
- If you use `mautic:maintenance:cleanup --gdpr` then all anonymous AND not anonymous will be deleted after 3 years.

Best,

N.

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 27, 2020, 7:59am UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/7 "2020-03-27T07:59:47Z")

</div>

Hi @npracht!

This is wonderful. Thank you! I need some clarification regarding two matters, though:

1. when using the --gdpr flag and the cron job removes non-anonymous contacts. Is all the data connected to that contact removed? Does the delete cascade through the db?
2. what makes a contact count as inactive? Is it only that it hasn’t opened any emails? Or is it also that we haven’t sent any emails to the contact?

---

<div class="post-metadata">

**Author:** ![npracht](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/npracht/32/240_2.png) [@npracht](https://forum.mautic.org/u/npracht)\
**Post date:** [March 27, 2020, 8:43am UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/8 "2020-03-27T08:43:23Z")

</div>

It is based on last active field. So email opened, page visited, form submited. That should be mainly all.  
Concerning the deletion, it should delete everything, we’re using same method as API deletion.

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [March 30, 2020, 10:19am UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/9 "2020-03-30T10:19:47Z")

</div>

Thank you! I appreciate it.

---

<div class="post-metadata">

**Author:** ![lalurran](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/lalurran/32/570_2.png) [@lalurran](https://forum.mautic.org/u/lalurran)\
**Post date:** [April 7, 2020, 7:27am UTC](https://forum.mautic.org/t/how-do-you-keep-the-data-in-your-mautic-db-trimmed-and-gdpr-compliant/13565/10 "2020-04-07T07:27:44Z")

</div>

@npracht @silavapi This is the output when we run

![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/6/6a27b81e1753b6488199f3e430af9043e88e0006.png)

It seems like more than audit log entries, visitors (anonymous contacts), and visitor page hits are affected? Or is user notifications an record type related to one of those?
