These steps are for a server with root access. They are not available on shared hosting.
Backups
Site backups cover the web root and the database. Mail sits somewhere else entirely, so it is quietly excluded - and years of correspondence is the one thing on a server that cannot be rebuilt from anything.
If the mailboxes are on your server
sudo rsync -aHAX --delete /var/vmail/ /srv/backup/vmail/
# then off-site
restic -r s3:s3.example.com/backups backup /srv/backup/vmail
Maildir stores one file per message, so this is incremental by nature: only new mail moves. Keep permissions with -aHAX or the mail server will not read what you restore.
If the mail is hosted elsewhere
You still need your own copy. A hosted mailbox is somebody else's disk and somebody else's retention policy, and a deleted-by-accident folder is often gone for good.
sudo apt-get install -y isync
# ~/.mbsyncrc
IMAPAccount work
Host mail.example.com
User sara@example.com
Pass "app-password"
SSLType IMAPS
mbsync -a # pulls everything to local Maildir
Test a restore of one message
Copy one folder back into a test account and open it in a client. Maildir with the wrong ownership restores perfectly and shows an empty mailbox, which is a bad thing to learn on the day.
