Work on DB cleanup tool

This commit is contained in:
Pablo Revilla
2025-09-19 10:50:15 -07:00
parent f9a6f3dff2
commit 02f63fca70
2 changed files with 35 additions and 2 deletions

View File

@@ -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.

View File

@@ -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