Lenses migration from H2 to Postgres is taking a long time

How can I speed up the migration of Lenses that uses the H2 database to PostgreSQL?

The migration can take a long time if your database is large. This is often due to Audit logs. Best practices is to integrate audits with your external SIEM/Security solution to avoid needing to keep a high retention rate on Lenses.

You can delete old and unused logs/audits.

Important: Ensure you have a backup of the current database directory as indicated in Lenses.storage.directory.

You can run a command to delete old log files to reduce the size of the database. The command will be the same for Lenses VM/Bare-metal or on Kubernetes, just make sure to verify where it is installed and adjust the database folder location if necessary.

Change the timestamp epoch shown below value to match your specific case. The command:

java -cp /opt/lenses/lib/h2-1.4.199.jar org.h2.tools.Shell -url jdbc:h2:file:/data/lenses/lensesdb -sql "DELETE FROM audits WHERE timestamp < 1699032060704"

If the command doesn’t work, you can stop the execution of Lenses and then run the command again.