Hello mailcows! Can I share my experience with mailcow backup? Official guide suggest to backup with cron, but I trick it a little, so the backups are made fully with systemd.
Take a look.
First we mount NFS filesystem somewhere in /mnt/nfs.
After we add systemd service:
/etc/systemd/system/backup-mailcow.service:
[Service]
Type=oneshot
WorkingDirectory=/opt/mailcow-dockerized
Environment=MAILCOW_BACKUP_LOCATION=/mnt/nfs
ExecStart=/usr/bin/rsync -aH –delete /opt/mailcow-dockerized ${MAILCOW_BACKUP_LOCATION}/opt_mailcow-dockerized
ExecStart=/usr/bin/rsync -aH –delete –exclude=backingFsBlockDev /var/lib/docker/volumes ${MAILCOW_BACKUP_LOCATION}/var_lib_docker_volumes
SuccessExitStatus=23
ExecStart=/opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup mysql crypt redis –delete-days 3
Please leave directory opt_mailcow-dockerized as is, because script backup-and_restore.sh, if launched with option –delete-days, delete everything older than 3 days with mailcow-* glob, so if opt_ will be ommited, full directory will be deleted.
After that create /etc/systemd/system/backup-mailcow.timer like this:
[Unit]
Description=Daily full backup (Mailcow + Docker volumes)
[Timer]
OnCalendar=--* 01:00:00
Persistent=true
[Install]
WantedBy=timers.target