Archive for the Back Up Category

Postfix Backup Script

Posted by Filed Under Back Up with Comments Off

Create a Simple Backup Script for Postfix
You need several different methods of backing up your mail server. One of those methods is using a compressed tar file of all of the important configuration files and directories that have content for Postfix.  In addition, you will need to add a timestamp for your backups to you can go back and dig out mail from the archives if needed.  The other advantage of a timestamp backup is that you will not overwrite previous backups.

Use vi or your favorite text editor and create this bash shell script.  The first line tells indicates that it is a bash shell script.  The lines that start with “#” are comments.  The TIMSTAMP line provides a date, right down to the second so that you will always have backups with different dates.  The script echos the TIMESTAMP so that it can be made available to the tar commands.  The tar commands create a backup with an ending of “.tar.gz” which will compress the backup to save space.  Note that the location for backup is listed and then the directory you want to backup is listed.  There are two main directories that you will want to backup, /etc and /var.  The /etc directory will contain the configuration for Postfix which is listed in /etc/postfix but also it will backup amavisd.conf, dovecot configuration, etc.  The /var directory has the actual mail that is saved in /var/spool/vhosts, the virus file is /var/virusmails, /var/clamav has your anti-virus database and /var/log has log files that you will want to retain for evaluation.  Please note that this backup could be large depending upon your mail traffic to take that into account if you automate it.

The example shows backing up to the /home directory but of course you will want to choose a partition that is on a separate drive from your mail server.  You will also see a number of exclude options so that you do not back up .gz files or .rpm files as these will drastically alter the size of the backup.

#!/bin/sh
#
# Timestamped Backup for Postfix
#
TIMESTAMP=`date +%Y%m%d_%H%M%S`;
echo $TIMESTAMP
tar czvf /home/postfix_$TIMESTAMP.tar.gz /etc
tar czvf /home/var_$TIMESTAMP.tar.gz –exclude=’*.gz’ –exclude=’*.rpm’ /var

Audit Outgoing Mail

Posted by Filed Under Back Up with Comments Off

Copy Outgoing Mail to Another Account

This will copy any mail sent by a user to an audit account as a copy.

Create a file called sender_bcc in /etc/postfix and edit the file so that you have two columns, the first column represents the user you want to audit and the second column is the user the mail is blind carbon copied.

tsmith@example.org audit@example.org

Hash the file with this command:

postmap hash:/etc/postfix/sender_bcc

Audit Incoming Mail

Posted by Filed Under Back Up with Comments Off

Copy Incoming Mail to Another Account
This setting will send a copy of all incoming mail to a specific users to another account for auditing purposes.

Add a line to the main.cf.

recipient_bcc_maps = hash:/etc/postfix/recipient_bcc

Create a file called recipient_bcc in /etc/postfix and edit the file so that you have two columns, the first column represents the user you want to audit and the second column is the user the mail is blind carbon copied.

tsmith@example.org audit@example.org

Hash the file with this command:

postmap hash:/etc/postfix/recipient_bcc