Blame SOURCES/cyrus-imapd.cron-daily

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