Files
emailwiz/docs/ROLLBACK.md
T

2.4 KiB

Backup and rollback

What is backed up

emailwiz backup and every emailwiz apply write /var/backups/emailwiz/<YYYYmmdd-HHMMSS>-<label>/ (directory mode 0700, files 0600):

  • config.tar.gz: /etc/postfix (includes the DKIM keys in /etc/postfix/dkim), /etc/dovecot, /etc/opendkim.conf, /etc/default/{opendkim,spamd}, /etc/fail2ban/jail.d, the opendkim/spamd systemd drop-ins, emailwiz timers, /etc/aliases, /etc/pam.d/dovecot, /etc/mailname, /etc/emailwiz, /var/lib/dovecot/sieve, and the certbot deploy hook;
  • MANIFEST: file list; SHA256SUMS: archive checksum (verified at creation);
  • created: files the corresponding apply created (removed on rollback);
  • retired/: second copy of files an apply retired.

--with-mail also archives ~/Mail of every member of group mail. Mailboxes are never restored by rollback; restore them manually if ever needed: sudo tar -C / -xpzf …/config.tar.gz home/USER/Mail.

Automatic rollback

apply restores the files from its own backup if postfix check, doveconf, opendkim -n or fail2ban-client -t fail, if a reload/restart fails, or if a service is inactive afterwards. It then exits with status 3.

Manual rollback

sudo emailwiz backups
sudo emailwiz rollback 20261028-150102-apply   # the apply you want to undo
sudo emailwiz validate

rollback verifies the checksum, saves the current state as a pre-rollback backup, removes files the original apply created, extracts the archive, runs newaliases, restarts the mail services and checks they are active.

Without emailwiz (last resort)

B=/var/backups/emailwiz/<id>
sudo sh -c "cd $B && sha256sum -c SHA256SUMS"
sudo tar -C / --numeric-owner -xpzf $B/config.tar.gz
sudo xargs -r rm -f < $B/created
sudo systemctl daemon-reload
sudo newaliases
sudo systemctl restart opendkim postfix dovecot spamd fail2ban

When to roll back

  • emailwiz validate reports FAIL items that weren't present before the apply;
  • mail stops arriving (journalctl -u postfix -f shows rejects) or clients cannot log in;
  • outbound mail is no longer DKIM-signed (journalctl -t opendkim).

Off-host copies

Backups live on the same disk as the server. Periodically copy them off the host, encrypted, because they contain the DKIM private key:

# on your workstation
ssh admin@mail.example.org 'sudo tar -C /var/backups -czf - emailwiz' | gpg -c > emailwiz-backups-$(date +%F).tar.gz.gpg