Shell Skript: Cyrus Backup Script V4
Mit diesem Skript können Sie ein Backup ihrer Cyrus-Postfächer erstellen. Bevor Sie das Skript ausführen, sollten Sie den Backuppfad anpassen.
Hinweis: Dieses Skript ist für CentOS 5.x ausgelegt.
###########################################################################
## ##
## Cyrus Backup Script V4 ##
## ##
## Creation: 16.06.2005 ##
## Last Update: 20.10.2013 ##
## ##
## Copyright (c) 2004-2013 by Georg Kainzbauer <http://www.gtkdb.de> ##
## ##
## This program is free software; you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/bash
# Location of the backup directory
BACKUPDIR=/data/backup/cyrus/
# Name of the backup archive
BACKUPFILE=cyrus_backup_`date +%Y_%m_%d_%H_%M`.tar.bz2
# Path of the Cyrus spool and account directory
SPOOLDIR=/var/spool/imap
ACCOUNTINGDIR=/var/lib/imap/user
# Log file
LOGFILE=/var/log/cyrus_backup.log
# Lock file
LOCK=/var/tmp/cyrus_backup.lock
###################################################################
# NORMALLY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
###################################################################
function log()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " LOG:" $1 | tee -a ${LOGFILE}
}
function error()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | tee -a ${LOGFILE}
exit 1
}
if [ -f ${LOCK} ] ; then
error "Lockfile ${LOCK} exists."
fi
touch ${LOCK}
if [ ! -d ${BACKUPDIR} ] ; then
log "Creating backup directory"
mkdir -p ${BACKUPDIR}
fi
log "Suspending mail system"
echo "Server Suspended ..." > /var/lib/imap/msg/shutdown
log "Starting backup process"
umask 066
su - cyrus -c "/usr/lib/cyrus-imapd/ctl_mboxlist -d" > /var/tmp/mailboxlist.txt
tar cjpf ${BACKUPDIR}${BACKUPFILE} ${SPOOLDIR} ${ACCOUNTINGDIR} /var/tmp/mailboxlist.txt
rm -f /var/tmp/mailboxlist.txt
log "Resuming mail system"
rm -f /var/lib/imap/msg/shutdown
postqueue -f
rm -f ${LOCK}
exit 0
## ##
## Cyrus Backup Script V4 ##
## ##
## Creation: 16.06.2005 ##
## Last Update: 20.10.2013 ##
## ##
## Copyright (c) 2004-2013 by Georg Kainzbauer <http://www.gtkdb.de> ##
## ##
## This program is free software; you can redistribute it and/or modify ##
## it under the terms of the GNU General Public License as published by ##
## the Free Software Foundation; either version 2 of the License, or ##
## (at your option) any later version. ##
## ##
###########################################################################
#!/bin/bash
# Location of the backup directory
BACKUPDIR=/data/backup/cyrus/
# Name of the backup archive
BACKUPFILE=cyrus_backup_`date +%Y_%m_%d_%H_%M`.tar.bz2
# Path of the Cyrus spool and account directory
SPOOLDIR=/var/spool/imap
ACCOUNTINGDIR=/var/lib/imap/user
# Log file
LOGFILE=/var/log/cyrus_backup.log
# Lock file
LOCK=/var/tmp/cyrus_backup.lock
###################################################################
# NORMALLY THERE IS NO NEED TO CHANGE ANYTHING BELOW THIS COMMENT #
###################################################################
function log()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " LOG:" $1 | tee -a ${LOGFILE}
}
function error()
{
echo `date +%d.%m.%Y%t%H:%M:%S` " ERROR:" $1 | tee -a ${LOGFILE}
exit 1
}
if [ -f ${LOCK} ] ; then
error "Lockfile ${LOCK} exists."
fi
touch ${LOCK}
if [ ! -d ${BACKUPDIR} ] ; then
log "Creating backup directory"
mkdir -p ${BACKUPDIR}
fi
log "Suspending mail system"
echo "Server Suspended ..." > /var/lib/imap/msg/shutdown
log "Starting backup process"
umask 066
su - cyrus -c "/usr/lib/cyrus-imapd/ctl_mboxlist -d" > /var/tmp/mailboxlist.txt
tar cjpf ${BACKUPDIR}${BACKUPFILE} ${SPOOLDIR} ${ACCOUNTINGDIR} /var/tmp/mailboxlist.txt
rm -f /var/tmp/mailboxlist.txt
log "Resuming mail system"
rm -f /var/lib/imap/msg/shutdown
postqueue -f
rm -f ${LOCK}
exit 0
Dieser Eintrag wurde am 08.01.2010 erstellt und zuletzt am 05.04.2015 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_33_840.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer