[Mailman-Developers] Backing up Mailman list installations
J C Lawrence
Mailman-Users@python.org, claw@kanga.nu
Wed, 28 Nov 2001 21:34:41 -0800
<<Reply-To: set>>
A moderately frequent request on these lists has been, "How can I
back up my Mailman lists/membership/etc?" I happened to be in the
area today touching up the scripts I use. Please feel free to adapt
freely.
Note: You'll need to have a reasonably recent version of nmh
installed as the scripts rely on the MH tools to build a MIME
message:
http://www.mhost.com/nmh/
The scripts:
~/bin/mimemail:
--<cut>--
#!/bin/bash
#set -x
subject=$1
file=$2
addr=$3
echo "To: ${addr}
From: nobody
Subject: ${subject}
#application/octet-stream [${subject}] ${file}
" | /usr/bin/mh/mhbuild - > /tmp/mimemail.tmp.${$}
/usr/lib/mh/post -verbose -watch /tmp/mimemail.tmp.${$}
rm /tmp/mimemail.tmp.${$}
--<cut>--
~/bin/mailman.backup
--<cut>--
#!/bin/bash
#set -x
datestr=`date +%Y%m%d`
host=`hostname -f`
file=mailman.lists.${datestr}.tar.gz
filepath=~/backups/${file}
sendto="root"
cd /var/lib/mailman
tar zcf ${filepath} lists
cd ~/backups
mimemail ${file} ${filepath} ${sendto}
#rm ${file}
--<cut>-
Yeah, there are some hard coded paths in there. Sue me. I never
said they were pretty, merely that they worked. Brief explanation:
mimemail takes three arguments: the Subject: of the message its
going to send, the file it is going to send, and the address it is
going to send it to. mimemail depends on the nmh tools to build
the MIME message.
mailman.backup takes no arguments. It creates a compressed
tarball of ~mailman/lists in the file
~/backups/mailman.lists.YYMMDD.tar.gz
eg: mailman.lists.20011128.tar.gz
And then uses mimemail to send that file to root@localhost
(edit/change if you want) before deleting it.
To use drop them in a cronjob something like:
0 6 * * 0 /home/archiver/bin/mailman.backup
A sample execution should look something like:
$ ./mailman.backup
-- Posting for All Recipients --
-- Local Recipients --
root: address ok
-- Recipient Copies Posted --
Message Processed
The result will be that every time the cronjob runs it will send you
(in this case root@host.dom) a message looking something like:
Subject: mailman.lists.20011128.tar.gz
From: nobody@kanga.nu
Date: Wed, 28 Nov 2001 21:12:55 -0800
To: root@kanga.nu
<MIME attachment application/octet-stream>
Where the MIME attachment is the tarball constructed by
~/bin/mailman.backup. Edit the value of sendto in mailman.backup if
you want them going somewhere else.
I've added this to FAQ at:
http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq04.006.htp
--
J C Lawrence
---------(*) Satan, oscillate my metallic sonatas.
claw@kanga.nu He lived as a devil, eh?
http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live.