Mailman - delete or backup old archived messages
Hello Mailman team!
I have been using Mailman-Suite (Hyperkitty + Postorius) quite a long time now and now i was wondering if there is any way to erase or export old archived messages and back them up elsewhere (for example messages, that are older then 1 year). Didnt find any suitable option under "python3 manage.py" command and also didnt find any up to date post which related to mailman3 and python3.
Additional info: *Database: Postgresql13 *Mailman version: 3.3.4 *Python version: 3.6
Br, Dim
On 6/17/21 1:00 AM, olenkoigetublim@gmail.com wrote:
I have been using Mailman-Suite (Hyperkitty + Postorius) quite a long time now and now i was wondering if there is any way to erase or export old archived messages and back them up elsewhere (for example messages, that are older then 1 year). Didnt find any suitable option under "python3 manage.py" command and also didnt find any up to date post which related to mailman3 and python3.
There isn't currently anything to do this but is shouldn't be difficult to create a script.
You'd need to import the Email class from hyperkitty.models.email, set CUTOFF to a datetime.datetime instance with the cutoff date instantiate a mbox to receive the deleted messages and then do something like
for email in Email.objects.filter(date<CUTOFF): msg = email.as_message() mbox.add(msg) email.delete()
A lot of required housekeeping such as importing django and calling django.setup(), exception handling and reporting would need to be added to the above, but the basic loop should work.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
Mark Sapiro
-
olenkoigetublim@gmail.com