Blame SOURCES/cyrus-imapd.cron-daily

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