From 02f63fca70024f3ae066e93e3c6b8a1f0ff0ffe3 Mon Sep 17 00:00:00 2001 From: Pablo Revilla Date: Fri, 19 Sep 2025 10:50:15 -0700 Subject: [PATCH] Work on DB cleanup tool --- README.md | 35 +++++++++++++++++++++++++++++++++++ sample.config.ini | 2 -- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8278ded..6255c37 100644 --- a/README.md +++ b/README.md @@ -179,6 +179,20 @@ password = large4cats [database] # SQLAlchemy connection string. This one uses SQLite with asyncio support. connection_string = sqlite+aiosqlite:///packets.db + +# ------------------------- +# Database Cleanup Configuration +# ------------------------- +[cleanup] +# Enable or disable daily cleanup +enabled = False +# Number of days to keep records in the database +days_to_keep = 14 +# Time to run daily cleanup (24-hour format) +hour = 2 +minute = 00 +# Run VACUUM after cleanup +vacuum = False ``` --- @@ -306,6 +320,27 @@ sudo systemctl daemon-reload ``` ## 5. Database Maintenance +### Database maintnance can now be done via the script itself here is the section from the configuration file. +- Simple to setup +- It will not drop any packets +``` +# ------------------------- +# Database Cleanup Configuration +# ------------------------- +[cleanup] +# Enable or disable daily cleanup +enabled = False +# Number of days to keep records in the database +days_to_keep = 14 +# Time to run daily cleanup (24-hour format) +hour = 2 +minute = 00 +# Run VACUUM after cleanup +vacuum = False +``` +Once changes are done you need to restart the script for changes to load. + +### Alternatively we can do it via your OS - Create and save bash script below. (Modify /path/to/file/ to the correct path) - Name it cleanup.sh - Make it executable. diff --git a/sample.config.ini b/sample.config.ini index c7bb878..b5dc57f 100644 --- a/sample.config.ini +++ b/sample.config.ini @@ -98,7 +98,5 @@ days_to_keep = 14 # Time to run daily cleanup (24-hour format) hour = 2 minute = 00 -# Number of rows to delete per batch -batch_size = 100 # Run VACUUM after cleanup vacuum = False \ No newline at end of file