Benno MailArchiv stores its data under different paths.
/srv/benno/archive/repo /srv/benno/archive/index/srv/benno/inbox/var/lib/benno-web The emails are stored in compressed form in the repository. The repository occupies by far the largest space in the archive's file system. No emails are deleted from the repository, so a backup only needs to save the files that have been added since the last backup.
A simple incremental network backup using system tools is a good option here.
A simple incremental backup to a locally mounted network share can be implemented with a simple script.
#!/bin/sh # # BACKUPDIR=/backup/benno-mailarchiv ARCHIVE_DIR=/srv/benno TS_FILE=$ARCHIVE_DIR/.last_backup START_DATE=`date +%Y%m%d%H%M.%S` if [ ! -f $TS_FILE ];then touch -t 200001010000 $TS_FILE fi /usr/bin/find $ARCHIVE_DIR -depth -newer $TS_FILE -print |\ tar -T - -cf ${BACKUPDIR}/benno-backup_$(date +%Y-%m-%d_%H-%M-%S).tar touch -t $START_DATE $TS_FILE
#!/bin/sh # # BACKUPDIR=/mnt/backup/$hostname ARCHIVE_DIR=/srv/benno TS_FILE=$ARCHIVE_DIR/.last_backup START_DATE=`date +%Y%m%d%H%M.%S` if [ ! -f $TS_FILE ];then touch -t 200001010000 $TS_FILE fi /usr/bin/find $ARCHIVE_DIR -depth -newer $TS_FILE -print |\ /bin/cpio --pass-through --preserve-modification-time --make-directories \ $BACKUPDIR touch -t $START_DATE $TS_FILE
The backup machine starts a script on the machine to be backed up via SSH, which creates a cpio archive from all newer files (benno2-create_cpio). This is then piped via SSH to the backup host and further processed there by another script.
# Backup Benno Mailarchive from remote host # # Benno Backup 20 1 * * * root ssh benno.lw-systems.net '/usr/local/sbin/benno2-create_cpio' | sh /usr/local/sbin/benno2-extract_cpio
This script is copied to the directory “/usr/local/sbin” on the backup machine.
#!/bin/sh # # cd /rsnapshot/benno-backups /bin/cpio -i \ --make-directories \ --no-absolute-filenames \ --preserve-modification-time
On the machine to be backed up, the script to generate the CPIO data stream is created in "/usr/local/sbin".
#!/bin/sh # # ARCHIVE_DIR=/srv/benno TS_FILE=$ARCHIVE_DIR/.last_backup START_DATE=`date +%Y%m%d%H%M.%S` /usr/bin/find $ARCHIVE_DIR -newer $TS_FILE | \ /bin/cpio -o touch -t $START_DATE $TS_FILE
Attention: The file .last_backup must be created for initialization.
touch -t 200001010000 /srv/benno/.last_backup
The index data of the indexed emails is stored in the index directory.
The index files are only written during the commit process. The index is committed no later than 10 seconds after the last email is written to it.
A backup can therefore be performed based on a hard link snapshot.
/etc/init.d/benno-archive stop sleep 10 cp -al /srv/benno/index /srv/benno/index_backup /etc/init.d/benno-archive start
The directory /srv/benno/index_backup can now be backed up safely.
A file backup can easily be performed here.