d0d307
#!/bin/sh
d0d307
#
d0d307
# This file is run on a daily basis to perform a backup of your
d0d307
# mailbox list which can be used to recreate mailboxes.db from backup.
d0d307
# Restore is done using ctl_mboxlist after uncompressing the file.
d0d307
d0d307
BACKDIR="/var/lib/imap/backup"
d0d307
MBOXLIST="${BACKDIR}/mboxlist"
d0d307
ROTATE=6
d0d307
d0d307
# fallback to su if runuser not available
d0d307
if [ -x /sbin/runuser ]; then
d0d307
  RUNUSER=runuser
d0d307
else
d0d307
  RUNUSER=su
d0d307
fi
d0d307
d0d307
# source custom configuration
d0d307
if [ -f /etc/sysconfig/cyrus-imapd ]; then
d0d307
  . /etc/sysconfig/cyrus-imapd
d0d307
fi
d0d307
d0d307
[ -x /usr/lib/cyrus-imapd/ctl_mboxlist ] || exit 0
Tomas Janousek 071176
[ -f /var/lib/imap/db/skipstamp ] || exit 0
d0d307
d0d307
# rotate mailbox lists
Tomas Janousek 6bba68
seq $[ $ROTATE - 1 ] -1 1 | while read i; do
d0d307
  [ -f ${MBOXLIST}.${i}.gz ] && mv -f ${MBOXLIST}.${i}.gz ${MBOXLIST}.$[ $i + 1 ].gz
d0d307
done
d0d307
[ -f ${MBOXLIST}.gz ] && mv -f ${MBOXLIST}.gz ${MBOXLIST}.1.gz
d0d307
d0d307
# export mailboxes.db
03b719
$RUNUSER - cyrus -s /bin/sh -c "umask 077 < /dev/null ; /usr/lib/cyrus-imapd/ctl_mboxlist -d | gzip > ${MBOXLIST}.gz"
d0d307
d0d307
exit 0
d0d307
# EOF