Projekt

Allgemein

Profil

Aktionen

MailCow » Historie » Revision 6

« Zurück | Revision 6/7 (Vergleich) | Weiter »
Jeremias Keihsler, 11.06.2024 08:39


MailCow

Backup-Mailserver

interesting article covering that topic
https://autoize.com/backup-mx-configuration-for-mailcow/

Backup

taken from https://mailcow.github.io/mailcow-dockerized-docs/b_n_r_backup/

create backup-target-location

mkdir /mnt/mailcow_backups

create daily-backup-script /etc/cron.daily/mailcow_backup.sh

#!/bin/sh

# Backup mailcow data
# https://mailcow.github.io/mailcow-dockerized-docs/b_n_r_backup/

set -e

OUT="$(mktemp)" 
export MAILCOW_BACKUP_LOCATION="/mnt/mailcow_backups" 
SCRIPT="/opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh" 
PARAMETERS="backup all" 
OPTIONS="--delete-days 30" 

# run command
set +e
"${SCRIPT}" ${PARAMETERS} ${OPTIONS} 2>&1 > "$OUT" 
RESULT=$?

if [ $RESULT -ne 0 ]
    then
            echo "${SCRIPT} ${PARAMETERS} ${OPTIONS} encounters an error:" 
            echo "RESULT=$RESULT" 
            echo "STDOUT / STDERR:" 
            cat "$OUT" 
fi

automatically delete mails older than in any given mailbox/folder

vim /usr/local/bin/tidyup_mailbox.sh
#!/bin/bash

# JKE 2023-10-16
# path to mailcow-dockerized
cd /opt/mailcow-dockerized

sudo docker compose exec dovecot-mailcow doveadm expunge -u 'user@example.com' mailbox 'FromServerMail' before 2w
sudo docker compose exec dovecot-mailcow doveadm expunge -u 'user@example.com' mailbox 'FromServerMail/Crond' before 6w
sudo docker compose exec dovecot-mailcow doveadm expunge -u 'user@example.com' mailbox 'FromServerMail/Fail2Ban_2' before 5d
sudo docker compose exec dovecot-mailcow doveadm expunge -u 'user@example.com' mailbox 'FromServerMail/Logwatch' before 2w
sudo docker compose exec dovecot-mailcow doveadm expunge -u 'user@example.com' mailbox 'FromServerMail/ztrash' before 1w

add this to cron

vim /etc/cron.d/tidyup_mailbox
# JKE 2023-10-16
#
#    min  hr   dom  month dow    user    command
#    -    -    -    -     -
#    |    |    |    |     |
#    |    |    |    |     +-day of week (0-7) sunday=0 or 7
#    |    |    |    +---------month (1-12)
#    |    |    +----------------day of month (1-31)
#    |    +-----------------------hour (0-23)
#    +------------------------------min (0-59)
#
     57   23   *    *     *    root    /usr/local/bin/tidyup_mailbox.sh

Debug

logs

in-memory logs are sometimes not enough ...
find mailcow.conf, start in it's directory

docker compose logs

statistics with pflogsumm

taken from https://docs.mailcow.email/manual-guides/Postfix/u_e-postfix-pflogsumm/

docker logs --since 24h $(docker ps -qf name=postfix-mailcow) | pflogsumm
# JKE 2024-06-11
#
#    min  hr   dom  month dow    user    command
#    -    -    -    -     -
#    |    |    |    |     |
#    |    |    |    |     +-day of week (0-7) sunday=0 or 7
#    |    |    |    +---------month (1-12)
#    |    |    +----------------day of month (1-31)
#    |    +-----------------------hour (0-23)
#    +------------------------------min (0-59)
#
     59   23   *    *     *    root    docker logs --since 24h $(docker ps -qf name=postfix-mailcow) | /usr/sbin/pflogsumm -d today | mail -s "Postfix Report of $(date)" postmaster@example.com

Von Jeremias Keihsler vor 5 Monaten aktualisiert · 6 Revisionen