2 0. Overview
Asif Bacchus edited this page 2020-05-07 04:51:41 -06:00

mailcow backup using borgbackup

This script automates backing up your Mailcow installation using borgbackup and a remote ssh-capable storage system. I suggest using rsync.net since they have great speeds and a special pricing structure for borgbackup/attic users (details here).

This script automates the following tasks:

  • Optionally copies a 503 error page to your webserver so users know when your server is unavailable due to backups being performed. The 503 file is removed when the backup is completed so users can login again
    • implementation of this feature is dependant on your particular webserver, this script only copies the file for your webserver to find
  • Dumps the Mailcow mySQL database and adds it to the backup
  • Handles stopping and re-starting mail-flow containers (postfix and dovecot) so everything is in a consistent state during the backup
  • Allows you to specify additional files you want backed up
  • Allows you to specify files/directories to exclude from your backups
  • Runs 'borg prune' to make sure you are trimming old backups on your schedule
  • Creates a clear, easy to parse log file so you can keep an eye on your backups and any errors/warnings

The script will backup the following items:

  • the entirety (including subdirectories) of whatever directory contains mailcow.conf
  • mailcow SQL database (standard SQL dump file will be generated)
  • the following mailcow volumes:
    • vmail (email)
    • rspamd (Rspamd settings including custom maps)
    • postfix
    • redis
    • crypt (your encryption keys!!!)
  • any directories/files listed in the plain-text file as specified by borgXtraListPath in backup.details

I've tried to explain all features as clearly as I can in this wiki but, if you have any questions or suggestions for improvements, please file an issue!

Hope this script helps you manage your backups a little easier :-)