BackingUpQmail

From Qmail Info Wiki

The list of what needs to be backed up in order to save the "state" of a qmail/vpopmail/courier-imap server...

for qmail:

   /var/qmail/alias
   /var/qmail/control
   /var/qmail/users
   /service/*/run (for any qmail-related services)
   /etc/tcp (or /etc/tcp.* if you keep your tcpcontrol files mixed with everything else)

for vpopmail:

   ~vpopmail/domains
   ~vpopmail/etc (everything except inc_deps or lib_deps)

for courier-authlib:

   /etc/authlib (or wherever your auth*rc files are)

for courier-imap: (whichever servers you are using)

   /usr/lib/courier-imap/etc/imapd
   /usr/lib/courier-imap/etc/imapd-ssl
   /usr/lib/courier-imap/etc/pop3d
   /usr/lib/courier-imap/etc/pop3d-ssl
   /service/*/run (if you're running courier-imap from daemontools)

as far as restoring them... the other server needs to be prepared ahead of time. you should compile qmail, vpopmail, courier-authlib, courier-imap, and whatever other packages you need, with exactly the same options you're using on the main server.

IN ADDITION, THE FOLLOWING USER AND GROUP ID'S MUST HAVE THE SAME NUMERIC VALUES ON BOTH SERVERS:

users:

   alias
   qmaild
   qmaill
   qmailp
   qmailq
   qmailr
   qmails
   vpopmail
   qscand (if you run qmail-scanner this way)
   clamav (if you run clamd)

groups:

   nofiles
   qmail
   vchkpw
   qscand (if needed)
   clamav (if needed)

As long as the backup server is set up correctly, restoring is just a case of copying the backed-up files into place and starting up the services.

Some example scripts to backup using rsync