Deleting and retaining contact data in Mautic for GDPR

How self-hosted Mautic applies GDPR storage limitation through its maintenance cleanup command, the GDPR contact flag, visitor and audit log purging, dry runs and backups.

On this page

Which GDPR retention duties Mautic's cleanup command helps with

If you run self-hosted Mautic as a controller, you must keep marketing contact and visitor data only as long as you need it, and you must be able to show how that limit is enforced. The mautic:maintenance:cleanup command, with its --gdpr flag, gives you a technical way to meet that storage limitation duty. It purges audit log entries, anonymous visitors and visitor page hits older than a number of days you set, and with --gdpr it deletes contacts that have been inactive for three years. Deletion is permanent, so the command is a control you configure and test, not a background tidy-up.

Treat the three-year inactivity rule as a Mautic setting, not a legal retention period. The GDPR (Regulation (EU) 2016/679) sets principles such as storage limitation but does not fix a number of years for marketing contacts, and it requires no certificate or audit attestation to show compliance. Your organization must decide how long each category of data is needed for its purpose, record that decision, and confirm that the lawful basis for keeping each record still holds. Whether three years fits your purposes, whether visitor and audit data need different periods, and whether any record must be kept longer for a legal reason are decisions for your legal and privacy team, not for the software.

Before you rely on the command, confirm the exact options and behavior in your Mautic release against the cron jobs documentation, and write down which age thresholds you chose and why. Ask your privacy lead to sign off the retention schedule, and ask your platform team to confirm how the cron job is scheduled and logged. A dry run shows what would be removed, but it does not replace a tested backup or a documented restore procedure, which are covered in the sections that follow.

Mapping storage limitation and security duties to Mautic cleanup settings

This table maps each GDPR duty to the Mautic setting or command that addresses it, the configuration each row needs, and where Mautic leaves a gap you must cover with process or other tooling. Read the gap column first, because the cleanup command does not remove everything that personal data touches in a Mautic instance.

RequirementMautic capabilityConfiguration neededGap or limit
Storage limitation for audit log entries (Article 5, applied through Article 24)maintenance:cleanup purges audit log entries older than a set number of daysSet the retention window in days that your retention schedule defines, and schedule the command through cronWindow is your decision; the documentation does not set a default you should adopt without review
Storage limitation for anonymous visitor datamaintenance:cleanup purges anonymous visitors and visitor page hits older than a set number of daysSet a visitor retention window in days, run with --dry-run first, then schedule the live runConfirm whether pages hits linked to known contacts are removed by the same run
Storage limitation for inactive contactsmaintenance:cleanup with --gdpr deletes contacts inactive for 3 yearsAdd the --gdpr flag only after confirming the 3-year inactivity rule matches your documented retention periodDeletion is permanent; the flag cannot be narrowed to a different period, so restore from backup is your only recovery
Safe rollout of destructive cleanup (Article 32 integrity and availability)--dry-run option reports what the cleanup would remove without deletingRun each cleanup variant in dry-run on a staging copy, record the output, then approve the live runDry-run output shows counts and scope; review it manually, it is not an approval workflow
Recovery before permanent deletion (Article 32 availability and resilience)No built-in undelete for cleanup resultsTake a verified database backup immediately before each live run and test restoring itBackup retention, encryption and restore testing are your responsibility, not a Mautic feature
Minimizing IP address data (Article 5 data minimization, Article 32 measures)Anonymize IP setting stops storing full visitor IP addressesEnable the setting in configuration before collecting visitor data, and document the decisionApplies to new data; confirm how historical full IP addresses are handled before enabling
Data outside Mautic tables (Articles 5 and 24 accountability)Not covered by the cleanup commandMap copies in CRM plugins, email transports, logs, exports and web server logs, and set deletion for eachConnected CRMs, mail providers and server logs keep their own copies; the command does not reach them
Evidence of retention decisions (Article 24 accountability)Command output and logs record what ran, if logging is enabledKeep your retention schedule, dry-run output and run logs together with change approvalsMautic does not produce a compliance record; the GDPR requires no audit or certificate, so your evidence is what you retain

How the maintenance cleanup command deletes data

The mautic:maintenance:cleanup command covers three separate targets, and each one needs its own retention decision. It purges audit log entries, anonymous visitors and visitor page hits that are older than a number of days you set. With the --gdpr flag it also deletes contacts that have been inactive for 3 years. The day thresholds for audit logs and visitor data are not fixed by the product in a way you can rely on for your own policy, so your data protection owner should set them from your documented retention schedule before the command is scheduled. Confirm the exact option names, defaults and the inactivity rule against the Mautic release you have installed, because the Mautic cron jobs documentation is version specific. Deletion is permanent, and the command does not move records to a recycle area you can restore from.

Run the command with --dry-run first on a copy of production data or on a staging instance that holds a recent restore. Review the reported counts for each target and compare them with what you expected from your retention rules. A contact count that is much higher than your estimate usually means the inactivity definition or the date threshold is not what you think it is, so stop and investigate before any live run. Record the dry-run output, the release version, the options used and the approver. That record becomes evidence of how storage limitation was applied, which is the kind of operational proof a reviewer will ask for.

Schedule the live command through the cron jobs Mautic documents, and stagger it away from the segment update, campaign update and campaign trigger jobs so that they do not compete for the database at the same time. Mautic's guidance on staggering those jobs applies here, so check the timing against your own load. Take a verified backup before the first live run and before any change to the thresholds, and keep the backup retention period in line with your policy, since a backup that still holds deleted contacts is a storage question your auditors will raise. Confirm the schedule, the frequency and the log location in your installed release, and make sure someone is alerted when the job fails.

Choosing retention periods for contacts, visitors and logs

Marketing contacts are the category that storage limitation reaches most directly. The mautic:maintenance:cleanup command with the --gdpr flag deletes contacts inactive for 3 years, and that deletion is permanent. The retention decision is whether three years of inactivity matches the purpose and legal basis you have recorded for each contact group, because the flag applies one rule to the whole database. The data protection officer or privacy lead should approve the period, and counsel should confirm the legal basis.

  • Inactivity as the trigger: The rule depends on how Mautic records activity, so confirm what counts as activity in your instance before relying on the flag.
  • One rule for all contacts: The flag applies the same three-year period to every contact, so groups with a different purpose or basis need a separate decision and possibly a different process.
  • Permanent removal: Take and test a backup before the first live run, because deleted contacts cannot be recovered from Mautic itself.
  • Named approvers: The privacy lead signs off on the period, and the marketing owner documents the business need for keeping inactive contacts.

Confirm the three-year figure with counsel and check whether any contact group needs a different period before you enable the flag.

Configuring cleanup and deletion safely in Mautic

This sequence turns a retention decision into a tested, logged cleanup routine, so contact deletion under the GDPR storage limitation principle is approved, reversible up to the backup point, and provable to an auditor.

  1. Document retention periods per data type

    The privacy or legal owner writes down how long each category of Mautic data may be kept: contacts, anonymous visitors, visitor page hits, audit log entries and backups. Engineering records which Mautic setting or cleanup flag governs each category. The step is done when the table is signed off and every category has a named owner and a stated purpose, so the GDPR storage limitation decision is written down before any command runs.

  2. Enable IP anonymization and confirm tracking settings

    The platform administrator turns on the Anonymize IP setting so Mautic stops storing full visitor IP addresses, then checks that tracking and cookie settings match the retention table. Confirm the change in the configuration file and by viewing a test visit record. Data already stored before the change is not rewritten by this setting, so the team must decide separately how to handle historical IP values.

  3. Take and verify a backup before deletion

    Before any permanent deletion, the operations team takes a full database backup and restores it to a separate environment to confirm it is readable and contains the expected contact counts. Record the backup identifier, time and location. The step is done when the restore check passes. Backups keep deleted contacts until they expire, so the backup retention period must be agreed in the same decision as the deletion schedule.

  4. Run the cleanup command in dry-run mode

    The administrator runs the mautic:maintenance:cleanup command with the dry-run option on the staging copy first, then on production, using the number of days agreed in the retention table. Save the full console output with the date and command line. Compare the reported counts for audit log entries, anonymous visitors, visitor page hits and contacts against the expected figures. The step is done when the output is filed and the counts match the approved scope.

  5. Obtain written approval for the GDPR run

    The privacy owner reviews the dry-run output, the backup record and the retention table, then approves the run in writing. The approval should name the --gdpr flag, which deletes contacts inactive for three years, and state that deletion is permanent. Stop here if counts differ from expectations or the backup check failed. The step is done when a signed approval record is linked to the change ticket.

  6. Schedule the GDPR run with staggered cron jobs

    Engineering adds the approved cleanup command to the scheduler on a fixed cadence, confirms that it does not run at the same time as segment, campaign or broadcast jobs, and documents the cron entries. Mautic's documentation says cron jobs should be staggered, so review the full crontab against that guidance. The step is done when a test run from cron completes and the schedule is recorded in the runbook.

  7. Log every run and review backup expiry

    After each scheduled run, the operator stores the command output, the start and end times, the approving record and the backup identifier in a retention log. Quarterly or on a cadence the owner sets, the team checks that backups older than the agreed retention period have expired or been removed. The step is done when the log is complete for the period and any gaps are assigned to an owner for correction.

Evidence to keep for an auditor reviewing deletion

An auditor reviewing deletion will ask whether the cleanup did what the retention schedule says, and whether anyone can show it. The cards below cover the records that connect Mautic's cleanup behavior to the security of processing and storage limitation review. DeployOpen prepares this evidence, but auditors and supervisory authorities judge whether it is adequate.

Dry-run output

Keep the output from running mautic:maintenance:cleanup with --dry-run before every change to the cleanup scope or the --gdpr run. The output shows which audit log entries, anonymous visitors and page hits would be removed, so it documents the intended effect before deletion becomes permanent. Compare the dry-run counts with the retention schedule and file the output with the change request. Check that the dry run was made against the same database and configuration the live job will use.

GDPR contact inactivity
3 years
Cron jobs docs

Cron configuration and run logs

Keep the crontab entries and the logs from each scheduled cleanup run. These show when the job ran, which options it used and whether it finished. Without them, you cannot show that deletion happens on the schedule you documented. Check that the --gdpr flag appears only where the approved schedule allows it, and that failed runs are investigated and rerun.

Written retention schedule with approvals

Keep a retention schedule that states each data type, its retention period, the legal basis for keeping it and the person who approved the period. Storage limitation is judged against this document, so it must match the cleanup settings in use. Record the review date and the reason for any change. Confirm with your privacy team which periods apply to each data category before configuring the job.

Backup and restore records

Keep records of backups taken before permanent deletion runs and of test restores. Because the cleanup removes data permanently, a backup is the only route to recover a record deleted in error. Record where backups are stored, who can access them and how long they are kept. Backup retention also counts as storage, so the schedule should cover backups too.

Anonymize IP configuration

Keep the saved configuration showing the Anonymize IP setting and the date it was enabled. This setting stops Mautic from storing full visitor IP addresses, which reduces the personal data held in visitor records between cleanup runs. Export the current configuration at each review and compare it with the value recorded in your processing documentation. Confirm the setting against the configuration settings reference for your Mautic version.

Configuration settings docs

Change records for cleanup settings

Keep a change log for every edit to the cleanup scope, the retention periods, the cron schedule and the Anonymize IP setting. Each entry should name the requester, the approver, the reason and the date. Auditors often test whether a retention period was changed to justify a deletion or retention result. Link each change record to the dry run and the approval that preceded it.

How deletion moves from schedule to permanent removal

The flow starts with an approved retention schedule that defines which contacts and records may be removed. Operators run the maintenance cleanup command with --dry-run first and review the candidate list before anything is removed. Only after that approval gate does a backup step run, followed by the scheduled cleanup with the --gdpr flag, which permanently deletes contacts inactive for three years. Check that backup retention is set so copies of deleted contacts do not outlive the schedule.

Deletion path from approved schedule through dry run, backup and permanent removal.

Questions buyers ask about deleting Mautic contact data

Does Mautic alone satisfy GDPR storage limitation for marketing contacts?

No. Mautic provides cleanup tooling, but it does not decide how long your organization may keep personal data. Storage limitation depends on retention periods you set for each data type, the lawful basis for keeping it, and how you document both. The three-year inactivity rule behind the --gdpr flag is a Mautic setting that you can run or leave out, so it has to match your own retention schedule. Your legal or privacy team should sign off on the periods before any deletion job runs.

What does a Mautic cleanup run involve in effort and who needs to be involved?

The command itself is short, but the work around it is not. The mautic:maintenance:cleanup command purges audit log entries, anonymous visitors and visitor page hits older than a number of days you choose, and it supports --dry-run so you can review counts first. The people involved usually include the marketing operations owner, the privacy lead who approves retention periods, and an engineer who schedules the job and confirms backups. Effort rises with the number of data types you purge and the amount of review needed before each run.

How long do setup and approval take, and what drives that?

The duration depends mostly on decisions that sit outside Mautic: agreeing retention periods per data type, confirming which records are needed for legal claims or consent evidence, and getting sign-off from the people accountable. Technical work includes testing the dry run on a copy of production data, confirming backup and restore steps, and setting the cron schedule so cleanup does not collide with other jobs. Ask any partner for a written timeline that lists which steps depend on your approvals, since those are usually the longest.

Can an internal team run Mautic deletion without a partner?

Yes, if the team has someone comfortable with the Mautic command line, cron scheduling and database backups, and if retention decisions are already documented. Internal teams often struggle with testing the dry run against realistic data, restoring from backup in a rehearsal, and keeping a change record that shows who approved each purge. A partner can fill those gaps on a fixed scope, while your team keeps ownership of the decisions. Compare both options against the skills and time your staff can commit.

What does the work need from our side before deletion starts?

Three things are needed before any run. First, written retention decisions for contacts, visitors, audit logs and any exported data, approved by the accountable owner. Second, a tested backup of the database and any file storage, with a restore you have rehearsed, because the cleanup is permanent. Third, administrative access to the Mautic instance, the server, the cron configuration and the backup system, with named people who can approve and reverse operational changes. Confirm each item in the scope document so no gap appears during the run.

Can deletion be reversed once the cleanup command has run?

Not from within Mautic. Deletion performed by the cleanup command is permanent, so recovery depends on backups taken before the run. Keep a backup that predates the job for a period your recovery plan defines, and test restoring it on a separate system. Also remember that copies may exist in other places, such as CRM integrations, email platforms or exported files, and those need their own deletion steps. Confirm with your vendors how each connected system handles deletion requests.

Do visitor IP addresses need separate handling from contact deletion?

Yes. Visitor data and contact data are handled by different parts of the cleanup, and the Anonymize IP setting stops Mautic from storing full visitor IP addresses, which helps with GDPR compliance. Confirm that the setting is enabled before the first run, and decide how long visitor records are kept before purge. Your privacy review should cover tracking cookies and any location data as well, since those can identify people even after contact records are removed.

What your compliance and engineering teams must decide before the first run

Before anyone runs a cleanup command against production, the controller must settle the questions the software cannot answer. The first is the legal basis and retention period for each category of data: marketing contacts, anonymous visitors, visitor page hits and audit log entries each serve a different purpose, so each needs its own justification. The three-year inactivity window that Mautic's --gdpr flag applies is a technical default, not a legal conclusion. Your compliance lead should confirm in writing that three years matches your documented retention schedule for contacts, and that the other periods you set for visitors and logs are defensible under your records of processing. Under the GDPR, these choices belong to the controller. The regulation is enforced by independent national supervisory authorities under Article 51, and administrative fines under Article 83 apply to controllers that fail to meet their obligations, including storage limitation and security of processing.

Next, decide who approves deletion and who can trigger it. A permanent purge should require a named approver from compliance or the data protection function, a recorded reason, and a dry run output saved as evidence before the live run. Decide how data subject requests interact with the scheduled cleanup, since an erasure request should be handled through its own documented process rather than left to the inactivity rule. Decide how long backups are kept. A purge removes data from the live database, but copies in older backups remain until they expire, so your retention period for backups must be stated and the restore procedure must explain how deleted contacts are excluded or removed if a restore is ever needed.

Finally, assign ownership. Cron jobs for the maintenance command, backup jobs and the restore runbook usually sit with the platform or engineering team, while the approval rules sit with compliance. Write both down so that nobody assumes the other team checked. The engineering owner should confirm how scheduled runs are logged and alerted, and the compliance owner should confirm where dry run and purge records are stored. Ask your implementation partner and internal team to document these owners before go-live, and review the Mautic cron jobs documentation against your chosen Mautic release so the schedule matches the version you run.

How DeployOpen scopes and documents Mautic deletion and retention

DeployOpen treats contact deletion and retention in Mautic as a written, reviewable control rather than a one-off script run. We scope the retention rules with your compliance and data protection owners, configure and test the cleanup behavior in your own infrastructure, and hand over the evidence your team needs to explain it.

How we scope

  • Agree in writing which contact, visitor and audit log data your retention rules cover and who approves each category.
  • Map the three-year inactivity rule for the GDPR cleanup flag against your own lawful basis and retention periods.
  • Confirm which Mautic instances, backups and connected CRM records fall inside the deletion scope before work starts.

How we build

  • Set up the maintenance cleanup schedule in cron with dry runs reviewed and logged before any permanent deletion is enabled.
  • Configure purge periods for audit log entries, anonymous visitors and visitor page hits to match the agreed retention schedule.
  • Test deletion on a restored copy of your data, checking that records removed from Mautic are not recreated by sync jobs.

How we hand over

  • Deliver a written runbook covering dry-run review, backup timing, deletion approval and how to recover from a mistaken run.
  • Document the retention settings, cron entries and deletion evidence in a form your compliance team can review.
  • Walk your operators through the procedure and record which steps they now perform without DeployOpen involvement.

How we support

  • Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work begins.
  • Ongoing support, Mautic upgrades and periodic retention reviews are available as a retainer.
  • Confirm with DeployOpen during scoping whether an independent auditor or your own assessor will review the retention evidence.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.