Blame SOURCES/cyrus-imapd.cron-daily

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