Archive the Audit trail
The audit trail can generate a high volume of data, so it is a good practice to periodically archive portions of it. An archive separates a portion of the data from the database and keeps it for long-term storage. This process involves the use of detaching QuestDB Partitions. Detached partitions can be added back in at a later date.
Archiving a partition improves query speed for current data, while providing a cost-effective way to store older data.
Prerequisites
Before you start, ensure you have the following:
A designated backup location, for example
~/rhize-archives/libre-audit.Access to the Rhize Kubernetes Environment
Optional: kubectx utilities
kubectxto manage multiple clusterskubensto switch between and configure namespaces easily
Optional: the k8 Lens IDE, if you prefer to use Kubernetes graphically
Also, before you start, confirm you are in the right context and namespace.
## context
kubectl config current-context
## namespace
kubectl get namespaceTo change the namespace for all subsequent kubectl commands to libre, run this command:
kubectl config set-context --current --namespace=libreSteps
To archive the Rhize Audit trail, follow these steps:
Access QuestDB admin console by port forwarding 9000 on the QuestDB service. Start by Identifying QuestDB Service using
$ kubectl get svc -n <namespace> | grep questForward the QuestDB console service port locally using
$ kubectl port-forward service/<quest-service-name> 9000 -n <namespace>Using the browser open http://localhost:9000 to the QuestDB console
Record the
<PARTITION_NAME>of the partition you wish to detach and archive. This is based on the retention-period query for the names of the existing partitions. Execute the following query in the QuestDB console.SHOW PARTITIONS FROM audit_log;
Detach the target partitions from the main table:
ALTER TABLE audit_log DETACH PARTITION WHERE time < '<TIMESTAMP i.e. 2025-12-31T23:59:59.99999Z>';
On success, the command renames the partitions in
/root/.questdb/db/audit_log*/<partition_name>to/root/.questdb/db/audit_log*/<partition_name>.detached.Move partitions out of QuestDB into cold storage:
Identify the name of the partitions detached in the audit_log directory:
$ kubectl exec -it questdb bash -c "ls /root/.questdb/db/audit_log*/*.detached -d -w 1"Example:
$ kubectl exec -it questdb bash -c "ls /root/.questdb/db/audit_log*/*.detached -d -w 1" /root/.questdb/db/audit_log~9/2025-12-15.detached /root/.questdb/db/audit_log~9/2025-12-16.detached ... /root/.questdb/db/audit_log~9/2025-12-31.detachedFor each partition copy it out of the pod:
kubectl cp questdb:/root/.questdb/db/<audit log directory>/<detached partition>.detachedExample:
kubectl cp questdb:/root/.questdb/db/audit_log~9/2025-12-15.detached 2025-12-15.detached Successfully copied 78.8kB to .\2025-12-15.detachedThen the partition can be removed from QuestDB
kubectl exec -it questdb rm -rf /root/.questdb/db/<audit log directory>/<detached partition>.detachedExample:
$ kubectl exec -it questdb bash -c "rm -rf /root/.questdb/db/audit_log~9/2025-12-15.detached"Repeat for any additional partitions.
Next Steps
- For full backups or Rhize services, read how to back up: