> Source: https://docs.cyberelements.io/bastion/4.6/Usage/AdminConsoleReference/LogDataCleanup/

# Log data cleanup

The **Log data cleanup** module lets the administrator purge the records piled up in Bastion's event database, and schedule that purge on a recurring basis. It is used when the database grows large, to comply with a retention policy, or ahead of an export. Two tabs coexist: **Immediate cleaning**, run on demand, and **Scheduled cleaning**, which runs automatically.

Both tabs offer the same selection of data to delete.

---

## Data to delete

The **All** checkbox covers every kind of data: ticking it **disables** the three groups below, which then no longer need to be filled in.

| Group | Checkboxes offered |
|---|---|
| **Action Type** | **Add**, **Modify**, **Delete**. |
| **Sessions** | **Close**, **Pause**, **Resume**. |
| **Information** | **Administration Console connections**, **Web portal connections**, **Applications launching**, **Applications closing**, **Gateways**, **HTML5 Gateways**, **User plugin**, **Direct sessions launching**, **Direct sessions closing**, **Actions on passwords**. |

Two settings complete the selection, outside the groups:

| Field | Description |
|---|---|
| **PostgreSQL VACUUM** | Checkbox. Additionally runs a `VACUUM` on the PostgreSQL database. On its own, it is enough to make the operation valid. |
| **Keep the last** | Period to exclude from the cleanup: an integer (minimum 0, default 2) followed by a unit — **Days**, **Months** or **Years**. Data more recent than that interval is preserved. The preselected unit differs per tab: **Years** in immediate cleaning, **Days** in scheduled cleaning. |

> **Nothing to clean**
>
> If nothing is ticked — no checkbox from the three groups, no **All**, no **PostgreSQL VACUUM** — the operation is refused with the **Nothing to clean** message.

---

## The "Immediate cleaning" tab

The tab carries a warning, in orange: **Warning: Cleaning may take several hours and significantly slow down the platform.**

1. Tick the data to delete (or the **All** checkbox).
2. Optionally adjust **Keep the last**.
3. Click **Start a cleaning**.

While it runs, the form is covered by a mask reading **Cleaning in progress**, and the **Cancel the cleaning** button becomes active. Clicking it displays **Canceling...**; data already deleted cannot be recovered.

Once the operation completes, a notification announces **The cleanup task is finished**.

> **State tracking**
>
> The tab polls the server **every 5 seconds** for the cleanup state. Tracking therefore resumes even if the module window is closed and reopened while the cleanup runs.

---

## The "Scheduled cleaning" tab

This tab stores a recurring cleanup configuration. It repeats the **Data to delete** box — same checkboxes as above — and adds a **Scheduling** box:

| Field | Description |
|---|---|
| **Disabled** *(default)* | No scheduled cleanup. |
| **Monthly** | Monthly cleanup, starting from the given date. |
| **Weekly** | Weekly cleanup, starting from the given date. |
| **Daily** | Daily cleanup. |
| **Next cleaning** | Date of the next cleanup, formatted `dd/mm/yyyy`. It cannot be earlier than the current date. One field is offered for the monthly mode, another for the weekly one. |
| **Cleaning hour** | Time of the cleanup, formatted `hh:mm` between `00:00` and `23:59`. Pre-filled with the current hour, minutes at zero. |

The **Validate** button saves the schedule. It **triggers no immediate cleanup**, and only acts on this tab: the checkboxes of the **Immediate cleaning** tab are not saved.
