Jens Günther writes:
-> I just don't see, how this would be easier :-D Read through it, but still don't know how to batch export and reimport config and/or users.
If you were expecting a single command, that would be available via the command line interface "mailman". There is no such thing yet.
What I meant by "easier" is that you can experiment with it and maintain state in the Python interpreter rather than having to store intermediate results in files and figure out how to read them back in. And you have all Python facilities (classes, lists, dicts) to organize data rather than needing to mess with text editing of JSON or trying to script things in exactly the right order (eg, to deal with read-only attributes).
Once you have an object, you can use the pickle module to save it (that's how Mailman 2 kept its configs, after all).
-> maybe it's again a dumb question, but how would I start it?
The easy way to experiment is
mailman shell
This starts a Python 3 interpreter with many of the base mailman classes and functions already imported. It's actually an alias for "mailman withlist", but I usually use "mailman shell" with no arguments and "mailman withlist -l $LIST" when I know what list I want to work with.
Once you know what you want to do, for list-oriented tasks you can use "mailman withlist -l $LIST -r $YOUR_SCRIPT" to do it repeatedly.
You'll need to be more "creative" with users and other non-list objects to write usable scripts, importing mailmanclient and any relevant core modules. See mailman/src/mailman/commands for many examples (including the source code for mailman shell and mailman withlist in the file cli_withlist.py. The "mailman" command line utility itself is in mailman/src/mailman/bin/mailman.py, but you don't need to look at that, it doesn't do much interesting for your purpose. And you can probably ignore all the @click decorators, they are used to get rid of boilerplate for managing command line arguments.
mailman shell and mailman withlist keep a history, I think it's configured in mailman.cfg or schema.cfg.
-> it it's easier, is there an easy way to export and import config? (or members?)
I don't understand what you're trying to do, so I can't say.
The usual use case is backing up a whole site either as a disaster recovery tool, or in order to move the site to a new host. For that an SQL database dump, and an archive of /etc/mailman3 and any changes you've made to templates or source files, is the way to go.
If you just want lists of addresses and the like, "mailman withlist" will do that for you.
But you seem to want self-contained pieces of the whole object- oriented database, and that's going to be harder because you need to maintain structure. There's no way around that.
Steve