How to archive old, closed tickets

As in the subject :slight_smile:

We need to clean our database (mysql) from tickets which has been closed
since some time ago, saving them in some kind of external storage (maybe
plain text files).
We need some automatic procedure doing that.
And we want to set different retention times, depending on factors like
which queue the ticket belongs to.
Or maybe the user who closed, or opened, the ticket.
Or the age of the uncle of the person named in the third word of the
subject :slight_smile:

Ok, I can understand it doesn’t exist yet, I’m ready to write something:
but I need suggestions from the list.
Can anybody help me?

TIA, Carlo