Blame SOURCES/cyrus-imapd.cron-daily

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