On 6/30/21 6:23 AM, Lucia Moreno wrote:
Hi Mark,
We are facing the same issue. My postgres database is growing too fast and I would need to do some creaning of old archives dated from 2001 and keep only the last, lets say... 5 years.
Could you please help us with the development of such a script? I have no experience in python.
The attached script is a rough idea. It assumes your Mailman is installed in a virtualenv at /opt/mailman/mm/venv and the django settings module is /opt/mailman/mm/settings.py.
The pruned messages will be in a mbox at /opt/mailman/pruned.mbox.
The age of messages to prune is defined by the days=365*5 argument in
CUTOFF = datetime.datetime.today() - datetime.timedelta(days=365*5)
All these things may need adjustment for your purpose.
There is also a commented bit showing how you could do just one list.
It's probably good to do just one list at a time since it's not clear how useful the pruned.mbox will be if it contains messages from multiple lists. I.e., run it for one list and move the pruned.mbox aside before doing the next list.
Note that I've tested that this works, but it's possible that it will leave HyperKitty in a bad state. Backup your database before running this.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan