#1010011 Periodically vacuum database to prevent it growing endlessly

Package:
fail2ban
Source:
fail2ban
Submitter:
Thijs Kinkhorst
Date:
2025-11-27 08:29:02 UTC
Severity:
normal
Tags:
#1010011#5
Date:
2022-04-22 09:29:29 UTC
From:
To:
Hi,

fail2ban (since 0.11) automatically cleans up stale entries in its
database, by default daily. However, the sqlite database is not
vacuum'ed so the file size on disk is not reduced after this. On one of
my systems, the database file was > 1 GB in size while after vacuum only
a 1 M remained, so it really was growing way to large.

The attached patch installs a weekly cronjob to perform the vacuum.
I've also submitted it as a merge request on salsa.


Kind regards,
Thijs Kinkhorst

#1010011#10
Date:
2025-10-21 13:46:24 UTC
From:
To:
Hi,

Calling VACUUM dwiwith on a running fail2ban may lead to errors:

    2025-10-21 15:36:28,210 fail2ban.filterpyinotify[496743]: ERROR   Error in FilterPyinotify callback: database is locked
    2025-10-21 15:36:33,216 fail2ban.filterpyinotify[496743]: ERROR   Error in FilterPyinotify callback: database is locked
    2025-10-21 15:36:38,222 fail2ban.filterpyinotify[496743]: ERROR   Error in FilterPyinotify callback: database is locked
    2025-10-21 15:36:43,227 fail2ban.filterpyinotify[496743]: ERROR   Error in FilterPyinotify callback: database is locked
    2025-10-21 15:36:48,232 fail2ban.filterpyinotify[496743]: ERROR   Error in FilterPyinotify callback: database is locked

So the approach of VACUUM'ing with cron.weekly would need stopping the daemon.

Alex

#1010011#17
Date:
2025-11-27 08:18:28 UTC
From:
To:
Would calling VACUUM in a systemd ExecStopPost work ?||