# H2 Database Purge Old Logs

### Overview

The H2 Database Purge feature ensures optimal database performance and prevents uncontrolled growth of the process\_table in the embedded H2 database. It automatically removes older records and their associated log files based on configurable retention limits.

This process runs periodically in the background and is controlled by the application to maintain a healthy system state without manual intervention.

***

### Why Purging is Needed??

* Over time, the process\_table accumulates large amounts of process logs.
* Without cleanup, the database can grow too large, impacting performance and consuming disk space.
* Purging helps maintain stability, speed, and optimal storage usage.

***

### How It Works

* The application automatically removes old process records and their corresponding log files based on a retention limit.
* Only the most recent logs are kept, ensuring you have access to the latest data while older entries are removed.
* This cleanup runs in the background every 2 days, requiring no manual intervention.

***

### Key Points

* Fully Automated: No action required from your side.
* Safe: Only older data is deleted; recent logs remain.
* Configurable: Retention limits can be adjusted based on your requirements.<br>

### Default Retention Policy

* The system keeps the most recent 250 records and 250 log files by default.
* If needed, these limits can be customized in the configuration.
* Older entries beyond these limits are automatically purged.

| Property Name    | Default Value | Description                                |
| ---------------- | ------------- | ------------------------------------------ |
| h2db.purge.limit | 250           | Number of latest database records to keep. |
| log.files.limit  | 250           | Number of latest log files to retain.      |

Older entries beyond these limits are automatically purged.

***

### Configuration Example

If you want to increase the retention limits, update your system.properties file:

\# Retain the latest 500 records in the H2 database

```
h2db.purge.limit=500
```

\# Retain the latest 500 log files

```
log.files.limit=500
```

***

### Benefits

* Improved Performance: Keeps the database lightweight and responsive.
* Optimized Storage: Prevents unnecessary disk usage.
* Hassle-Free: Automatic, no maintenance required.

***

{% hint style="info" %}
Note: If your compliance or audit requirements need longer retention, export logs periodically before they are purged
{% endhint %}

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mydbsync.com/cloud-replication-main/troubleshooting/h2-database-purge-old-logs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
