Clean up anonymous and outdated sessions

The following will greatly reduce database file size (usually by 80-90%, depending when cleared last) and should be done once or twice a year:

root@lamb:~$ sqlite3 /var/local/trac/bewelcome/db/trac.db
sqlite> DELETE FROM session WHERE last_visit < strftime('%s', 'now', '-1 year')
OR authenticated = 0;
sqlite> DELETE FROM session_attribute WHERE authenticated = 0;
sqlite> VACUUM;

Note: The first SQLite statement also influences which users are available in the "reassign to" select box of a ticket. In this case it will be every user that logged in less than a year ago.

Bulk remove trac tickets

When in need to remove several tickets at once, i.e. when fighting spam, type this:

root@lamb:~$ for n in $(cat spam-list.txt); do trac-admin /var/local/trac/bewelcome/ ticket remove $n; done

spam-list.txt needs to be a flat list of tickets with one number per line. Alternatively you can use "for n in 123 445 666;" to start the for loop.

Last modified 7 years ago Last modified on Sep 17, 2012, 9:56:35 AM