🇩🇪 Deutsch 🇬🇧 English

27 Apr 2019

Move Mailman Mailinglists to another server

Every few years it may happen that you have to move your mailman maling lists to a new host. With this guide loses its horror.

These instructions and scripts are FreeBSD-centric, but it would work under Linux analogously with changes.


Export

  1. Display the lists on the source host and export the config of the lists to be migrated
    #  cd /usr/lib/mailman/bin/
    #  ./list_lists
    3 matching mailing lists found:
            List-1 - Just some mailing list
            List-2 - Just another mailing list
           TheList - The list we are interested in
    #  ./config_list -o /tmp/TheList.conf TheList
    
  2. Export members of the following lists: regular und digest
    #  cd /usr/lib/mailman/bin/
    #  ./list_members -o /tmp/TheList-regular.txt -r TheList
    #  ./list_members -o /tmp/TheList-digest.txt -d TheList
    
  3. Export lists archive
    #  cd /var/lib/mailman/archives/private
    #  ls -lF
    total 32K
    drwxrwsr-x 12 root mailman 4.0K Jan 15  2011 List-1/
    drwxrwsr-x  2 root mailman 4.0K Apr  9  2010 List-1.mbox/
    drwxrwsr-x  4 root mailman 4.0K Nov 24  2010 List-2/
    drwxrwsr-x  2 root mailman 4.0K Nov 23  2010 List-2.mbox/
    drwxrwsr-x 55 root mailman 4.0K Sep  2 03:27 TheList/
    drwxrwsr-x  2 root mailman 4.0K Apr  8  2010 TheList.mbox/
    drwxrwsr-x  2 root mailman 4.0K Apr  7  2010 mailman/
    drwxrwsr-x  2 root mailman 4.0K Apr  7  2010 mailman.mbox/
    #  tar czf /tmp/TheList-archive.tgz TheList
    #  tar czf /tmp/TheList-mbox-archive.tgz TheList.mbox
    

All important files of the mailing lists are now exported to /tmp/. Now copy them to the destination server via scp or your preferred other method.


Import

  1. Now the import of the list on the target server begins. To do this, the list must first be created there: (–quiet prevents the list administrator from being notified by email)
    # ./newlist --quiet
    Enter the name of the list: TheList
    Enter the email of the person running the list: owner@example.com
    Initial TheList password:
    
  2. The config of the list can now be imported:
    #  ./config_list -i /tmp/TheList.conf TheList
    
  3. The Members can now be imported:
    #  ./add_members -r /tmp/TheList-regular.txt TheList
    #  ./add_members -d /tmp/TheList-digest.txt TheList
    
  4. If you are lucky, you can also import the archive. This is not mandatory.
    #  cd /var/lib/mailman/archives/private
    #  tar xzf /tmp/TheList-archive.tgz
    #  tar xzf /tmp/TheList-mbox-archive.tgz
    
  5. Finally fix the permissions
    #  chown -R root:mailman TheList TheList.mbox
    

This works, i have done this several times. If you have many mailing lists, it can be much handwork. Therefore i wrote this small shell scripts, only for me, hope that helps you, too.


Mailman Export Script

The mailing-lists-to-export must be set from hand. And please try to understand the script bevor using! The same applies to the import script.

#!/usr/local/bin/bash

# commands
MPRE=/usr/local/mailman/bin
LIST_LISTS=$MPRE/list_lists
CONFIG_LIST=$MPRE/config_list
LIST_MEMBERS=$MPRE/list_members

TAR=/usr/bin/tar

#archive location
LIST_ARCHIVE=/usr/local/mailman/archives/private

#where to save export
OUT_DIR=~/lists

declare -a lists=('Baumlist' 'Bildung' )

for i in `seq 0 $(( ${#lists[@]} - 1 ))`
do
list_lower=`echo ${lists[$i]}|tr '[:upper:]' '[:lower:]'` 
echo "Nr: $i - Name: ${lists[$i]} ($list_lower)"
$CONFIG_LIST -o ${OUT_DIR}/${lists[$i]}.conf ${lists[$i]}
$LIST_MEMBERS -o ${OUT_DIR}/${lists[$i]}-regular.txt -r ${lists[$i]}
$LIST_MEMBERS -o ${OUT_DIR}/${lists[$i]}-digest.txt -d ${lists[$i]}
$TAR czf  ${OUT_DIR}/${lists[$i]}-archive.tgz -C ${LIST_ARCHIVE} $list_lower
$TAR czf  ${OUT_DIR}/${lists[$i]}-mbox-archive.tgz -C ${LIST_ARCHIVE} ${list_lower}.mbox
done


Mailman Import Script

#!/usr/local/bin/bash

#name of list host
LIST_HOST=mail.example.de

#archive location
LIST_ARCHIVE=/usr/local/mailman/archives/private

#where to get export to import
IN_DIR=~/lists

# commands
MPRE=/usr/local/mailman/bin
LIST_LISTS=$MPRE/list_lists
CONFIG_LIST=$MPRE/config_list
LIST_MEMBERS=$MPRE/list_members
NEWLIST=$MPRE/newlist
ADD_MEMBERS=$MPRE/add_members

TAR=/usr/bin/tar

# lists to handle, get with $LIST_LISTS and add which you want
declare -a lists=('Baumlist' 'Bildung' )

for i in `seq 0 $(( ${#lists[@]} - 1 ))`
do
list_lower=`echo ${lists[$i]}|tr '[:upper:]' '[:lower:]'`
echo "Nr: $i - Name: ${lists[$i]} ($list_lower)"

## newlist [options] [listname [listadmin-addr [admin-password]]]
$NEWLIST -u ${LIST_HOST} -e ${LIST_HOST} ${lists[$i]} admin@example.com secret

$CONFIG_LIST -i ${IN_DIR}/${lists[$i]}.conf ${lists[$i]}
$ADD_MEMBERS -r ${IN_DIR}/${lists[$i]}-regular.txt --welcome-msg=n ${lists[$i]}
#$ADD_MEMBERS -d ${IN_DIR}/${lists[$i]}-digest.txt --welcome-msg=n ${lists[$i]}

$TAR xzf  ${IN_DIR}/${lists[$i]}-archive.tgz -C ${LIST_ARCHIVE}/
$TAR xzf  ${IN_DIR}/${lists[$i]}-mbox-archive.tgz -C ${LIST_ARCHIVE}/
done