User Tools

Site Tools


docs:tips_n_tricks:fail2ban.html

fail2ban

Cleanup oversized fail2ban.sqlite3

Test

cp -vip --sparse=always /var/lib/fail2ban/fail2ban.sqlite3 /scratch/root/fail2ban.sqlite3.sparse
sqlite3 fail2ban.sqlite3
sqlite3 $PWD/fail2ban.sqlite3 "VACUUM ;"
TMPDIR=/scratch/tmp/ sqlite3 $PWD/fail2ban.sqlite3 "VACUUM ;"

Real

systemctl stop fail2ban
cd /var/lib/fail2ban
TMPDIR=/scratch/tmp/ sqlite3 $PWD/fail2ban.sqlite3
  SELECT COUNT(*) FROM bans WHERE timeofban < STRFTIME('%s','2022-03-01');
  DELETE FROM bans WHERE timeofban < STRFTIME('%s','2022-03-01') LIMIT 10000;
  DELETE FROM bans WHERE timeofban < STRFTIME('%s','2022-03-01') LIMIT 10000;
  DELETE FROM bans WHERE timeofban < STRFTIME('%s','2022-03-01') LIMIT 35000;
  DELETE FROM bans WHERE timeofban < STRFTIME('%s','2022-03-01') ;
ls -lah fail2ban.sqlite3
TMPDIR=/scratch/tmp/ sqlite3 $PWD/fail2ban.sqlite3 "VACUUM ;" && systemctl start fail2ban
ls -lah fail2ban.sqlite3
docs/tips_n_tricks/fail2ban.html.txt · Last modified: 13.08.2022 02:24 CEST by peter